My solution has a
C# application project C# User Controls project C++ Mathematics projectOne of the UserControls uses function from the Mathematics (C++ projec开发者_Python百科t). This UserControl
is used in the application.
Building and starting the application works just fine. When typing the IntelliSense suggests all the contained classes and methods. The UserControl
appears correctly, but on clicking a button which calls the C++ function I get a BadImageFormatException
(it pops out on the end of the automatically created Main function).
The help suggests to use /fixed:no
for linking, but that is already set up.
You can get BadImageFormatException when running a 32bit dll on a 64bit system. Try setting the target to "x86" on all your projects.
Based on the information you are giving, it sounds like the managed code is trying to call into the C++ DLL as if it were managed code (and it is maybe built as unmanaged code). The information about BadImageFormatException discusses this:
An attempt is made to load an unmanaged dynamic link library or executable (such as a Windows system DLL) as if it were a .NET Framework assembly.
If you are building the C++ project as unmanaged code, you may need to use p/invoke to call into it.
精彩评论