我有一个在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
这个错误是什么意思? 任何帮助都非常感谢
答案 0 :(得分:1)
您的开发平台 32位,您部署的平台为64 bit
。选择调试类型 AnyCPU 程序集在加载到64 bit
进程时将JIT转换为 64位代码,而32 bit
加载到32 bit
时处理。已发布的汇编/从属程序集很可能与64位不兼容,需要处于32位进程。
您可以阅读有关选择目标平台及其对here的影响的更多信息。