SOAP客户端代码中的BadImageFormatException [英] BadImageFormatException from SOAP client code

查看:62
本文介绍了SOAP客户端代码中的BadImageFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多在OS(例如32位Windows XP)上运行.NET 4 SOAP客户端的站点都报告了以下示例.

A number of sites running a .NET 4 SOAP client, on OS's such as Windows XP 32-bit, are reporting exeptions like the one below.

我们无法始终如一地复制它.它仅在数千个站点中的3个或4个站点上发生过.有人知道与此相关的任何已知问题吗?有没有解决方法?我们尝试过多次重新安装.NET.

We can't reproduce it consistently. It has only happened on 3 or 4 sites out of thousands. Does anyone know of any known issue that might relate to this? Is there a workaround? We've tried reinstalling .NET a number of times.

 

System.BadImageFormatException:无法加载从系统,版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089'或其依赖项之一加载的文件或程序集'0字节.试图加载格式错误的程序.
文件名:从系统加载的0字节,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089" ---> System.BadImageFormatException:错误的IL格式.
  在System.Reflection.RuntimeAssembly.nLoadImage处(Byte [] rawAssembly,Byte [] rawSymbolStore,证据,StackCrawlMark& stackMark,布尔值introspection,SecurityContextSource securityContextSource)
  在System.Reflection.Assembly.Load(字节[] rawAssembly,字节[] rawSymbolStore,证据securityEvidence)
  在Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters选项,String []文件名)
  在Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters选项,String []源)中
  在Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters选项,String []源)
  在System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters选项,String []源)中
  在System.Xml.Serialization.Compiler.Compile(组件父级,字符串ns,XmlSerializerCompilerParameters xmlParameters,证据)
  在System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping [] xmlMappings,Type []类型,字符串defaultNamespace,证据,XmlSerializerCompilerParameters参数,程序集程序集,哈希表程序集)
  在System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping []映射,类型类型)
  在System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping []映射,类型类型)
  在System.Web.Services.Protocols.SoapClientType..ctor(类型类型)
  在System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()

System.BadImageFormatException: Could not load file or assembly '0 bytes loaded from System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: '0 bytes loaded from System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ---> System.BadImageFormatException: Bad IL format.
   at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, SecurityContextSource securityContextSource)
   at System.Reflection.Assembly.Load(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence securityEvidence)
   at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
   at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
   at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
   at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)
   at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
   at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
   at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
   at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
   at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
   at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()

....

 

推荐答案

这似乎与处理器体系结构有关.我的意思是,我认为您已经在任何CPU"(模式将在32位系统中以32位模式运行,在64位计算机中以64位模式运行.但是,我猜您的应用程序使用了一些dll 是为特定的CPU体系结构(x86或x64但不是AnyCPU)构建的.对于实例,如果您的任何dll是针对x86模式构建的(这意味着它包含32位指令),则该dll无法在64位计算机.

It looks to be an issue with the processor architecture. I mean, I think you have built your code in "Any CPU" mode which will run in 32 bit mode in 32 bit systems and in 64 bit mode in 64 bit machines. But, I guess, your application uses some dll which is built for specific CPU architecture (either x86 or x64 but not AnyCPU). For instance, if any of your dll is built against x86 mode (which means it contains 32 bit instructions) then, the dll cannot be executed in 64 bit machines.

因此,检查是否有任何dll(尤其是COM dll)具有特定于32位计算机的指令.如果是,则需要在x86模式下编译应用程序.这样,当您启动应用程序时,默认情况下会启动32位进程.而你的32位 dll可以正常运行.

So, Check whether any dll (especially a COM dll) has instructions specific to 32 bit machines. If yes, then you need to compile your application in x86 mode. By this, when you start your application, by default 32 bit process is started. And your 32 bit dll will run without any issues.

我希望这会有所帮助.


这篇关于SOAP客户端代码中的BadImageFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆