应用程序中的服务器错误 - 尝试访问WCF服务时

问题描述:

我有一个WCF服务,我想在IIS 7.5中托管。我的设置: 带有.svc文件的文件夹的物理路径是:C:\ inetpub \ wwwroot \ SmartSolution \ Services \ Services \ ContainerManagementService.svc 我的二进制文件位于C:\ inetpub \ wwwroot \ SmartSolution \ Services \ bin和我也将它们复制到 C:\ inetpub \ wwwroot \ SmartSolution \ Services \ Services \ bin应用程序中的服务器错误 - 尝试访问WCF服务时

我已经在IIS中为两个Services文件夹创建了一个Web应用程序。

下面是WCF端点配置文件:

 <service behaviorConfiguration="MyNamespace.ContainerManagementServiceBehavior" 
    name="MyNamespace.ContainerManagementService"> 
    <endpoint address="" binding="basicHttpBinding" 
     name="ContainerManagementbasicHttpEndpoint" contract="MyNamespace.IContainer"/>     
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service>  
    <behaviors>  
    <behavior name="MyNamespace.ContainerManagementServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
    </behavior> 
</behaviors> 

这里是我的.svc文件makrkup:

<%@ ServiceHost Language="C#" Debug="true" Service="MyNamespace.ContainerManagementService" CodeBehind="ContainerManagementService.svc.cs" %> 

当我尝试导航到:http://localhost/SmartSolution/Services/Services/ContainerManagementService.svc,将显示以下错误:

服务器错误 '/ SMARTSOLUTION/Services/Services' 应用程序。 [ServiceActivationException: 服务 '/SMARTSOLUTION/Services/Services/ContainerManagementService.svc' 无法在编译期间由于 异常而被激活。 异常信息是:不是有效的 Win32应用程序。 (例外从 HRESULT:0x800700C1)。]不是有效的 Win32应用程序。 (例外从 HRESULT:0x800700C1)

我怎样才能让服务工作。谢谢!

看看例外情况,看起来您的程序集(在bin文件夹中)是针对x64 Plaform构建的,现在它们既可以部署在32位机器上,也可以配置为应用程序池,以便应用程序在32位模式下运行(启用32位应用程序=“true”)。因此,进程无法加载为x64平台构建的程序集,并因异常而失败。

HTH 阿米特

+2

实际修复是这样的:1.内IIS(7)单击应用程序池。 2.在列表中找到为您的Web应用程序配置的应用程序池。 3.选择它,然后单击右侧的高级设置。 4.列表中的第二项设置:启用32位应用程序 - 必须设置为True。 – laconicdev 2011-03-29 19:39:43

+0

非常感谢您的评论 – 2014-09-30 11:53:14