2015-09-22 52 views
0

我有一个WCF托管在ASP.NET应用程序中。突然间,当我在visual studio 2010中调试它时,WCF服务停止工作。当我尝试访问服务时,它会抛出下面的异常。在Visual Studio中调试时WCF不工作,但在IE中工作

CommunicationException was unhandled by user code. The remote server returned an error: NotFound

我启用了WCF跟踪,但没有记录错误。

奇怪的是,如果我将代码部署到我的QA服务器并访问应用程序,该服务工作正常,所以代码看起来不是问题。

如果我还得到当前在生产中运行的源代码&尝试在我的开发环境中进行调试,它会失败,并出现上面提到的相同错误。

任何人都有一个想法可以在我的开发环境中搞砸了什么?我已经尝试了IE浏览器,火狐& Chrome &的结果是一样的。

+0

没有代码和/或配置示例,指出可能的原因是非常困难的... –

回答

0

我经过很长的调试,涉及删除Bin & obj文件夹和大量的重建,我终于得到这个WCF服务再次工作。

首先,我怀疑服务可能会损坏,所以我尝试更新我的Silverlight应用程序中的服务引用,但碰到以下错误。

There was an error downloading ' http://localhost/mySite/Webservice/GetData.svc '. The request failed with HTTP status 404: Not Found. Metadata contains a reference that cannot be resolved: ' http://localhost/mySite/Webservice/GetData.svc '. The remote server returned an unexpected response: (405) Method Not Allowed. The remote server returned an error: (405) Method Not Allowed.

我再浏览到物理文件夹路径,以确认是否真的是我的.svc文件在那里,果然,该文件在那里。

试图浏览到我的浏览器中的路径http://localhost/mySite/Webservice/GetData.svc在下面碰到另一个错误。

HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension.

Most likely causes: Request filtering is configured for the Web server and the file extension for this request is explicitly denied.

这让我开始思考,突然之间,IIS 7.0决定阻止访问我的.svc文件。 然后,我添加fileExtension =“。svc”mimeType =“application/octet-stream”到IIS,重新启动IIS,但得到相同的错误。

然后我读了一些博客,我不记得在位于C:\ Windows \ System32 \ inetsrv \ Config的applicationHost.config文件中的<requestFiltering>标记下添加<add fileExtension=".svc" allowed="true" />标记,仍然没有任何变化。试图在同一个文件中加入<mimeMap fileExtension=".svc" mimeType="application/octet-stream" />,serverSideInclude,再次没有运气。

试过这个http://www.adamwlewis.com/articles/iis-7-not-serving-files-4047-error仍然没有运气。

以下两个步骤是我认为是什么解决了这个问题。

  1. 我添加了SVC扩展到ASP.NET的映射通过在C运行ServiceModelReg.exe -i:\ WINDOWS \ Microsoft.NET \框架\ 3.0 \ Windows通讯基础

在浏览器中浏览我的.svc文件,这一次看起来我已经取得了一些进展,但仍然有一个错误需要克服。下面是。

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

  • 我通过注册使用ASP ASP.NET的正确版本解决了上述错误。如下
  • https://msdn.microsoft.com/en-us/library/hh169179(v=nav.70).aspx

    中的链接描述此时NET IIS注册工具(Aspnet_regiis.exe)我的服务已恢复正常,因为它一直是。我仍然没有弄清楚我的开发机器有什么问题。

    相关问题