tags:

views:

114

answers:

3

I have compiled a .Net application (using Any Cpu) option. This .Net application use Unmanaged dll ( Managed wrapper ) that encapsulated c++ calls.

This .Net wrapper resides in GAC.

When I run the .Net application it runs fine on XP 32 bit.

But when I run on XP 64 bit , it fails and gives follwoing exception: Could not load file or assembly "Dll name version Culture = neutral Public token key ....

or one of its dependencies..

Pleas Help to resolve the pb?

+3  A: 

You need to use the x86 CPU option. If you know that one of your unmanaged dependencies is 32bit then you need to build your solution with the x86 option for the CPU. This ensures that even on a 64bit operating system your application will be run in a 32 bit process.

This is required because its not possible to load 32 bit compiled code into a 64 bit process.

AnthonyWJones
Does Any CPU option won't suffice for this?
Ashish Ashu
No it won't. The "Any CPU" option allows a single assembly to built that will run on either 32 to 64 bit. When run on a 64 bit operating system .NET will start a 64 bit process and use the 64bit version of the JIT compiler. Hence you get an error when that code subsequently attempts to load a 32bit only dll. You must specifically indicated that .NET should only run the code in a 32bit process regardless of the OS its running on by specifying x86.
AnthonyWJones
A: 

You can find some explanation on Microsoft Connect website

Bolek Tekielski
-1: The link isn't the same issue as this question.
Cameron MacFarland
A: 

You need to make sure your unmanaged dll is also 64bit capable and within the search path.

leppie