当我开发WCF服务或网站解决方案时,我总是使用带有自定义配置文件的IISExpress,这样我就可以与团队中的其他开发人员共享设置。基本上,我运行一个批处理文件,其中包含以下命令:
"C:\Program Files(x86(\IIS Express\iisexpress.exe"/config:service-hosts.config
其中service-hosts.config是我的自定义配置文件的路径。
这种方法一直运行得很好,在我电脑上的其他解决方案中仍然运行良好(每个解决方案都有自己的service-hosts.config文件(。然而,我刚开始在使用此方法加载WCF服务时遇到问题。当我试图浏览到服务根目录或任何内置的帮助端点时,我得到了以下错误:
HTTP错误500.19-内部服务器错误无法访问请求的页面,因为该页面的相关配置数据无效。
详细错误信息:
模块IIS Web核心
通知未知
处理程序尚未确定
错误代码0x80070003
配置错误无法读取配置文件
配置文件\?\D: \Projects\MyProject\WCFSite\web.config
请求的URL http://localhost:80/
物理路径
登录方法尚未确定
登录用户尚未确定
请求跟踪目录C:\Users\Spikeh\Documents\IISExpress\TraceLogFiles\
配置来源:
-1:
0:
更多信息:
当读取Web服务器或Web应用程序的配置文件时出现问题时,就会发生此错误。在某些情况下,事件日志可能包含有关导致此错误的原因的更多信息。
如果您看到文本"定义了重复的'system.web.extensions/scripting/scriptResourceHandler部分",则此错误是因为您正在.NET Framework 4中运行基于.NET Framework 3.5的应用程序。如果您正在运行WebMatrix,要解决此问题,请转到"设置"节点,将.NET Framework版本设置为".NET 2"。您还可以从web.config文件中删除额外的部分。
查看更多信息»
我已经调试了几个小时,无法更改这个错误,更不用说修复它了
我试着用几个不同版本的applicationHosts.config覆盖我的service-hosts.config文件,用64位运行IISExspress,用一个非常基本的版本替换web.config文件,设置目录权限(到我电脑上的每个用户都可以访问的程度(,并更改应用程序池,但仍然没有更改。
奇怪的是……当我将WCF项目更改为在项目属性的Web部分使用"IISExpress",然后调试项目时,一切都很好。。。即使我的所有web.config设置都已就位。
这指向我如何运行IISExpress,或我的service-hosts.config文件。。。尽管service-hosts.config文件(对所涉及的站点进行了轻微修改(与我的其他项目中的文件完全相同。
有一件事需要注意(可能是转移注意力(,但我确实将解决方案从VS2012降级到了VS2010,并将框架目标更改为.Net 4.0……不确定是否因此而配置了一些有趣的东西?
有人有什么想法吗?我快要从屋顶上跳下来了。。。
更新:
以下是IISExpress的调试信息(使用/trace:e运行(:
Running IIS...
Starting IIS Express ...
Initializing the W3 Server Started CTC = 5514916
PreInitSitesThread: Premature Exit Occured ( hr = 80070003 )
W3 Server initializing WinSock. CTC = 5514916
W3 Server WinSock initialized. CTC = 5514916
W3 Server ThreadPool initialized (ipm has signalled). CTC = 5514916
Start listenerChannel http:0
Successfully registered URL "http://*:80/" for site "MyWebsite" application "/"
Registration completed for site "MyWebsite"
AppPool 'MyCustomAppPool' initialized
InitComplete event signalled
IIS Express is running.
Enter 'Q' to stop IIS Express
IncrementMessages called
Request ended: http://localhost:80/ with HTTP status 500.19
这是我的service-hosts.config:的重要部分
<applicationPools>
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_BIN%configtemplatesPersonalWebServeraspnet.config" autoStart="true" />
<add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_BIN%configtemplatesPersonalWebServeraspnet.config" autoStart="true" />
<add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_BIN%configtemplatesPersonalWebServeraspnet.config" autoStart="true" />
<add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_BIN%configtemplatesPersonalWebServeraspnet.config" autoStart="true" />
<add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />
<add name="IISExpressAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_BIN%configtemplatesPersonalWebServeraspnet.config" autoStart="true" />
<add name="MycustomAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%configaspnet.config" autoStart="true" />
<applicationPoolDefaults managedRuntimeLoader="v4.0" >
<processModel/>
</applicationPoolDefaults>
</applicationPools>
<listenerAdapters>
<add name="http" />
</listenerAdapters>
<sites>
<site name="MyWebsite" id="1">
<application path="/" applicationPool="MyCustomAppPool">
<virtualDirectory path="/" physicalPath="D:ProjectsMyProjectWCFSite" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
<webLimits />
似乎service-hosts.config文件指向了它不应该指向的东西。我用一个旧项目(因此是IISExpress/.Net Framework的旧版本(的副本替换了我的service-hosts.config,一切都很好。
听起来这毕竟与我的4.5->4.0降级有关。