执行当前 Web 请求期间发生 WCF 未处理的异常

本文关键字:WCF 未处理 异常 Web 请求 执行 | 更新日期: 2023-09-27 17:55:37

我有一个在VS2008中构建的WCF服务当我发布服务并在 IIS 中运行它时(在应用程序池中启用了 32 位应用程序),那么很好,它可以工作。但是当我尝试调试应用程序(所有项目的平台目标是任何 CPU)时,出现以下错误:

Common Language Runtime detected an invalid program.
Description: An unhandled exception occurred during the execution of the current web     request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.InvalidProgramException: Common Language Runtime detected an invalid program.
Source Error: 
An unhandled exception was generated during the execution of the current web request.   Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 
[InvalidProgramException: Common Language Runtime detected an invalid program.]
   System.ServiceModel.HostingManager..ctor() +0
   System.ServiceModel.ServiceHostingEnvironment.EnsureInitialized() +463
   System.ServiceModel.ServiceHostingEnvironment.OnEnsureInitialized(Object state) +185
   System.ServiceModel.PartialTrustHelpers.PartialTrustInvoke(ContextCallback callback,     Object state) +314
   System.ServiceModel.ServiceHostingEnvironment.SafeEnsureInitialized() +209
   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e)     +295
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +344
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +557

这个错误是什么意思??任何帮助都非常感谢

执行当前 Web 请求期间发生 WCF 未处理的异常

您用于开发的平台是 32 位,您部署的平台是 64 bit 位。选择调试类型 AnyCPU 程序集在加载到进程中时将 JIT 为 64 位代码64 bit在加载到32 bit进程中时32 bit。已发布的程序集/依赖程序集很可能与 64 位不兼容,需要采用 32 位进程。

您可以在此处阅读有关选择目标平台及其影响的更多信息。