应用程序中的服务器错误 - 尝试访问 WCF 服务时
-
14-11-2019 - |
题
我有一个 WCF 服务,我想将其托管在 IIS 7.5 中。我的设置:.svc 文件所在文件夹的物理路径为:c: inetpub wwwroot smartsolution services services containManagementService.svc我的二进制文件在c: inetpub inetpub wwwroot wwwroot smartsolution smartsolution services bin,我也将它们复制到c: inetpub inetpub inetpub inetpub inetpub wwwroot f。 垃圾桶
我已经在 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 文件标记:
<%@ ServiceHost Language="C#" Debug="true" Service="MyNamespace.ContainerManagementService" CodeBehind="ContainerManagementService.svc.cs" %>
当我尝试导航到: http://localhost/SmartSolution/Services/Services/ContainerManagementService.svc ,显示以下错误:
服务器错误在“/smartsolution/services/services”应用程序中。[服务激活异常:服务'/smartsolution/services/services/containersanagementservice.svc'由于编译过程中的例外而无法激活。例外消息是:不是有效的Win32应用程序。(Hresult的例外:0x800700C1)。]不是有效的Win32应用程序。(Hresult的例外:0x800700C1)
我怎样才能让服务正常工作。谢谢!
解决方案
查看例外情况,您的程序集(在 bin 文件夹中)似乎是针对 x64 平台构建的,它们现在要么部署在 32 位计算机上,要么为应用程序配置的应用程序池在 32 位模式下运行(启用 32 位应用程序 =“true”) )。因此,进程无法加载为 x64 平台构建的程序集,并且会出现异常失败。
Hth Amit