Take the 2-minute tour ×

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 to 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();

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?

share|improve this question
Possible duplicate to: stackoverflow.com/questions/5478904/… –  BitKFu Apr 28 '11 at 7:36
People put effort into helping you by answering your question. Deleting this would result in them losing reputation. If your issue is solved by some other means, leave an answer with your solution and select it when the option to do so becomes available. This helps people who have similar issues and does not penalize those that tried to help you. –  Will Apr 28 '11 at 13:37
add comment

2 Answers

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.

share|improve this answer
i already did that with no success. Just edited my question, it may be a 16bit dll?! –  Martin Booka Weser Apr 28 '11 at 7:38
I don't think, that the DLL is build as 16bit one.. Can you post the PE header type? –  cevik Apr 28 '11 at 12:11
Also, are you executing in the right working directory? Look at this: stackoverflow.com/questions/5743895/… –  cevik Apr 28 '11 at 12:19
add comment
up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer


