2014-09-30 175 views
1

我已经用netTcpBinding创建了一个在ASP.NET Web应用程序中托管的WCF服务。我想让它运行,但我总是得到“未设置为引用的对象” - 错误。WCF netTcpBinding:为什么我不能调试,为什么不稳定?

我首先创建了我的服务并使用默认绑定对其进行了测试。它的工作,我得到了我的预期结果返回。

因为我不想通过HTTP运行它,而是通过TCP,我改变了我的绑定如下:

<system.serviceModel> 
<services> 
    <service name="be.xxx.xxx.WCF.Leasing"> 
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="be.xxx.xxx.WCF.ILeasing" /> 
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="net.tcp://localhost/be.xxx.xxx.WCF/Leasing.svc"/> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior> 
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 

在项目属性,我在网上下改变它应该在“本地IIS”下运行。将项目URL设置为http://localhost/be.xxx.xxx.WCF并单击“创建虚拟目录”按钮。

enter image description here

我也改变了我的IIS设置:

  • 应用程序池.Net框架v4.0.30319,集成
  • 在 “高级设置”,我已经添加了“网。 tcp“用于启用协议。

我的Windows服务“Net.Tcp监听器适配器”和“Net.TCP端口共享服务”都在运行。

我可以浏览到http://localhost/be.xxx.xxx.WCF/Leasing.svc,告诉我,我已经创建了一项服务。

所以,当我通过按F5开始调试(VS是根据管理员权限运行),我得到了以下画面: enter image description here

OK,当我开始独立WCF测试客户端,我参考http://localhost/be.xxx.xxx.WCF/Leasing.svc/mex,它加载的功能: enter image description here

首先,它完全没有说“对象引用未设置为对象的实例”异常。 就在建立这个问题时,它跑了,让我回到预期的结果。 我不敢相信这次运行的原因,所以我再次关闭了WCF测试客户端,并重新尝试了我的努力。现在它再次给我提供了“未设置为对象实例的对象引用”异常。 enter image description here

我也尝试将服务引用添加到测试控制台应用程序,但这给我同样的问题。因此,为什么我不能在Visual Studio(〜找不到metdata)进行调试,并且为什么看起来不稳定(只运行一次)?为什么我不能在Visual Studio中调试(〜找不到metdata)?

回答

1

您是否尝试过定义HTTP MEX结合

+0

我已经改变了'<端点地址= “MEX” 绑定= “mexHttpBinding” bindingConfiguration = “” 合同= “IMetadataExchange接口”/>'现在我可以在VS中调试。 Thx – JurgenStillaert 2014-09-30 10:16:01

+0

虽然这似乎解决了OP的问题,但这个答案相当糟糕,因为没有解释或附加信息。如果您添加了提供更多详细信息的信息,这将是一个很好的答案。 – Tim 2014-09-30 16:43:48

相关问题