开发者

Loading Corflags:16 dll into x86 application crashes on 64bit system

I am using an external dll in my project. When i try to run the application on a 64bit machine, it crashes with a FileLoadException. Since it works fine on a 32bit system, i suspect the dll to be 32bit. However, setting the project's target platform to x68 doesn't help.

I read 32bit dll in 64bit application in c# and Load 32bit DLL library in 64bit application and some other pages that tell i should build the whole app as a 32bit process (which wouldn't bother me - it should just be executable on a 64bit windows), but i don't know how t开发者_如何转开发o build a 32bit app on a 64bit dev machine if not by setting the target platform...

The code is just

static void Main(string[] args)
{
    var mf = new QuickFix43.MessageFactory();
    Console.WriteLine("running");
    Console.ReadKey();
}

and the QuickFix stuff is from the dll.

Edit: I checked the dll with CorFlags and figured

CLR Header: 2.5
PE        : PE32
CorFlags  : 16

which means that the dll is a Mixed-mode assembly that can be loaded only in an i386 environment ( http://blogs.msdn.com/b/slessard/archive/2010/04/09/types-of-managed-code-assemblies.aspx )

Is is it possible to load this in an 64bit environment?


You can also run 32bit applications on an 64bit environment. But if you want to load a 32bit DLL you must build your application as a 32bit one. You can do this by setting the target platform to x86 in the "Debug" and "Release" mode. This should solve your problem.


OK, so heres the answer. The problem was actually not that my project could not load the native dll. The problem was that my project calls a managed dll that calls the native dll in question. The target platform of my project was set to x68 but the managed dll was compiled as "any cpu". Recompiling the intermediate managed dll with x68 worked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜