I am developing a C++/CLI wrapper, for a dll which has been developed in QT 4.5 . I have only the QT dll and its header file. The QT dll is a 32 bit dll.
When I am trying to call my C++/CLI wrapper from my C# console application , I am seeing the BadImageException.
using GWrapper;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("WELCOME");
GWrapper wrapper = new GWrapper();
wrapper.CallAMethod(someText);
}
}
If I keep only the Console.Writeline("WELCOME")
there is no exception
I am on Windows 7 64 bit, and would like to keep x86 as the preferred option, as the application needs to run on 64 bit systems as well.
Project settings :
Wrapper in C++/CLI - Win32
C# console application - x86
Output from CORFLAGS
C++/CLI wrapper ( Output is a DLL, and references a 32 bit QT dll )
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 16
ILONLY : 0
32BIT : 0
Signed : 0
I set the 32 bit flag for the DLL to 1, but the exception was still there. When I rebuilt the dll, its was set to 0 again.
C# Console application ( Output is a EXE)
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 3
ILONLY : 1
32BIT : 1
Signed : 0
How do I make the console application work with the wrapper ?
ANY CPU
? Did you doublecheck the Configuration Manager if for sure both projects compile asc# --> x86
andc++/cli --> Win32
– t3chb0t