Reputation: 346
I wrote a wrapper DLL for some native c++ functions and compiled it in c++/CLI, then I added a reference to C# project, functions indicates there, but when I try compile project I get this error:
Additional information: Could not load file or assembly 'lib, Version=1.0.3742.39593, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
What's the problem ?
Upvotes: 1
Views: 469
Reputation: 116744
64-bit vs 32-bit incompatibility is the most common cause of that error.
In the Project settings page of the C# project your Platform target
will be set to Any CPU
. This means that on a 64-bit system the program will run in a 64-bit process. It will then be unable to load DLLs that target 32-bit (native DLLs can't switch to suit the process.)
So you need to set it to x86. In VS2010 the default will be x86 for new projects.
Upvotes: 3