x86上的WCF服务错误错误的图像格式异常 [英] WCF Service Error Bad Image Format Exception on x86

查看:81
本文介绍了x86上的WCF服务错误错误的图像格式异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从任何CPU将Platform Target更改为x86时,出现错误的错误图像格式异常.
在任何CPU"上作为平台目标运行时,它不会引发异常.

我的操作系统是Win 7 x64.我发现使用64位框架会引发异常.
日志:使用来自C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ config \ machine.config的计算机配置文件."

现在的问题是我正在使用Sybase数据库,并且我具有32位dll,而不是x64.
因此,如果选择"Any CPU"并运行该服务,则在创建连接对象时,内存位置将出现异常.
AseConnection oAseCon =新的AseConnection(str);

有没有一种解决方案,我可以在64位计算机上的WCF服务中运行第三方32位dll.

帮助将不胜感激.

谢谢

I am getting an error Bad Image Format Exception when i change the Platform Target to x86 from Any CPU.
It doesn''t throw an exception when running on "Any CPU" as Platform Target.

My OS is Win 7 x64. I figured out that as 64-bit framework being used, it is throwing the exception.
"LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config."

Now the problem is i am using Sybase database and i have a 32-bit dll and not x64.
So if "Any CPU" is selected and i run the service, i am getting exception for memory location just while i create a connection object.
AseConnection oAseCon = new AseConnection(str);

Is there a solution that i can run a 3rd party 32-bit dll in a WCF Service on 64 bit machine.

Help would be appreciated.

Thanks

推荐答案

我试图将32位dll放在Bin目录以及SYSWOW64目录中.
问题是当我在任何CPU"模式下运行时..初始化32位dll时出现错误,并且将Platform Target更改为x86时出现以下错误.

注意:这是我正在运行的WCF服务,当我尝试使用WCF服务"WcfTestClient.exe"的默认客户端启动时,出现此错误.

"

System.BadImageFormatException:无法加载文件或程序集"file:///C:\ Users \ CShah \ Documents \ Visual Studio 2010 \ Projects \ SilverLight \ SSQueueServiceLibrary \ bin \ Debug \ SSQueueServiceLibrary.dll"或其依赖项之一.试图加载格式错误的程序.
文件名:``file:///C:\ Users \ CShah \ Documents \ Visual Studio 2010 \ Projects \ SilverLight \ SSQueueServiceLibrary \ bin \ Debug \ SSQueueServiceLibrary.dll''
在System.Reflection.RuntimeAssembly._nLoad(AssemblyName文件名,字符串codeBase,证据assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,布尔throwOnFileNotFound,布尔值用于自省,布尔值preventSecurityChecks)
在System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据assemblySecurity,StackCrawlMark&stackMark,布尔值用于自省,布尔值抑制SecurityChecks)
在System.Reflection.Assembly.Load(AssemblyName assemblyRef)处
在Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)

===预绑定状态信息===
日志:用户= CShah
日志:where-ref绑定.位置= C:\ Users \ CShah \ Documents \ Visual Studio 2010 \ Projects \ SilverLight \ SSQueueServiceLibrary \ bin \ Debug \ SSQueueServiceLibrary.dll
日志:Appbase = file:///C:/Users/CShah/Documents/Visual Studio 2010/Projects/SilverLight/SSQueueServiceLibrary/bin/Debug
日志:初始PrivatePath = NULL
调用程序集:(未知).
===
日志:此绑定从LoadFrom加载上下文开始.
WRN:不会在LoadFrom上下文中探测本机映像.仅在默认的加载上下文中探测本机映像,例如Assembly.Load().
日志:使用应用程序配置文件:C:\ Users \ CShah \ Documents \ Visual Studio 2010 \ Projects \ SilverLight \ SSQueueServiceLibrary \ bin \ Debug \ SSQueueServiceLibrary.dll.config
日志:使用主机配置文件:
日志:使用C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ config \ machine.config中的计算机配置文件.
日志:尝试下载新的URL文件:///C:/Users/CShah/Documents/Visual Studio 2010/Projects/SilverLight/SSQueueServiceLibrary/bin/Debug/SSQueueServiceLibrary.dll.
ERR:无法完成装配的设置(hr = 0x8007000b).探测终止."
I tried to place the 32 bit dll in Bin directory and also SYSWOW64 dir.

The problem is when i run in "Any CPU" mode .. i get error while initializing the 32 bit dll and when i change the Platform Target to x86 i get the following error.

Note: This is WCF Service which i am running and i get this error when i try to start with Default Client for WCF Service "WcfTestClient.exe".

"

System.BadImageFormatException: Could not load file or assembly ''file:///C:\Users\CShah\Documents\Visual Studio 2010\Projects\SilverLight\SSQueueServiceLibrary\bin\Debug\SSQueueServiceLibrary.dll'' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: ''file:///C:\Users\CShah\Documents\Visual Studio 2010\Projects\SilverLight\SSQueueServiceLibrary\bin\Debug\SSQueueServiceLibrary.dll''
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)

=== Pre-bind state information ===
LOG: User = CShah
LOG: Where-ref bind. Location = C:\Users\CShah\Documents\Visual Studio 2010\Projects\SilverLight\SSQueueServiceLibrary\bin\Debug\SSQueueServiceLibrary.dll
LOG: Appbase = file:///C:/Users/CShah/Documents/Visual Studio 2010/Projects/SilverLight/SSQueueServiceLibrary/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\CShah\Documents\Visual Studio 2010\Projects\SilverLight\SSQueueServiceLibrary\bin\Debug\SSQueueServiceLibrary.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Users/CShah/Documents/Visual Studio 2010/Projects/SilverLight/SSQueueServiceLibrary/bin/Debug/SSQueueServiceLibrary.dll.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated."


这篇关于x86上的WCF服务错误错误的图像格式异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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