添加WCF服务引用失败。 VS2008退出

时间:2020-03-06 14:49:47  来源:igfitidea点击:

我有一个超级简单的WCF服务。我使用IIS7将其托管在本地计算机上。

当我向我的服务添加服务引用时,Visual Studio会告诉我有一个错误。我可以单击"详细信息"链接,然后弹出一个对话框,其中:对象引用未设置为对象的实例。

我可以毫无问题地构建WCF服务,并且我的客户端应用程序也可以成功构建。

我什至可以使用svcutil http://localhost/logservice/logservice.svc?wsdl生成客户端。

我在Windows事件日志/查看器中看到了此错误:

.NET运行时版本2.0.50727.3053致命执行引擎错误(706B7706)(80131506)

我在网上找到了修补程序,但是无法安装...

我认为这与我从中添加服务引用的客户端解决方案有关。我可以使用"在解决方案中发现服务"功能添加服务记录。我只需要在其他地方的解决方案中添加服务引用,这会让我发疯。

我的web.config的system.serviceModel如下所示:

<system.serviceModel>
<services>
  <service behaviorConfiguration="LogServiceBehavior" name="LogService">
    <endpoint address="" binding="wsHttpBinding" contract="ILogService">
      <identity>
                    <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="LogServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

解决方案

我尝试将问题隔离开来,从目前的解决方案转移到完全没有复杂性的新解决方案中。

  • 从WCF服务模板在Visual Studio中创建一个新的网站。
  • 将C#3.5类库项目添加到解决方案中。
  • 构建解决方案。
  • 在ClassLibrary1项目上添加Service Reference,然后单击发现按钮以发现此解决方案中的WcfService1.
  • 我们将在列表中看到WcfService1,但是当我们单击"确定"或者尝试扩展发现的服务时,我们会收到错误消息。有时VS2008会退出-却没有任何提示。

我试过运行C:\ Windows \ Microsoft.NET \ Framework \ v3.0 \ Windows Communication Foundation> ServiceModelReg.exe -r,但无济于事。

有没有人遇到过这样的事情?