0

当我开发 WCF 服务或网站解决方案时,我总是使用带有自定义配置文件的 IISExpress,这样我就可以与团队中的其他开发人员共享设置。基本上,我运行一个批处理文件,其中包含以下命令:

"C:\Program Files (x86)\IIS Express\iisexpress.exe" /config:service-hosts.config

其中 service-hosts.config 是我的自定义配置文件的路径。

这种方法一直运行良好,并且在我的 PC 上的其他解决方案中仍然可以正常运行(每个都有自己的 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 文件,设置目录权限(到每个我的 PC 上的用户有权访问),并更改应用程序池,但仍然没有更改。

奇怪的是......当我将 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%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
    <add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
    <add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
    <add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
    <add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />
    <add name="IISExpressAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />

    <add name="MycustomAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.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:\Projects\MyProject\WCFSite\" />
        </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 />

4

1 回答 1

1

似乎 service-hosts.config 文件指向了它不应该指向的东西。我用旧项目的副本替换了我的 service-hosts.config(因此是旧版本的 IISExpress / .Net Framework),一切正常。

听起来这毕竟与我的 4.5 -> 4.0 降级有关。

于 2013-02-25T08:28:46.330 回答