how to call a C++ dll from C# windows application project
- by chathuradd
I have created a dll in C++ using a Class Library project in Visual Studio. I need to call a method in the dll from a C# application.
I got to know there are 2 approches. One is to add the dll project reference to C# project or use DllExport to export method. However when I tried in both ways it always gives the following error when the dll method is called in runtime.
An unhandled exception of type 'System.BadImageFormatException' occurred in TestClient.exe
Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Can i know how to avoid this problem ?
Thanks in advance!