Search code examples
c#c++visual-studiodllmarshalling

How to convert or use Win32 libraries to another platform?


Description-:

I am trying to implement Marshaling, trying to use C++ libraries in C# code in Visual Studio.

I have a C++ project that runs perfectly fine when build in Win32 solution platform, but when build in x64 solution platform throws error-: enter image description here

And i have C# program that runs on x64, x86 or AnyCPU platform.

And if i try to build C++ project in Win32 platform and use the dll's created into x64,x86 or AnyCPU platform of my c# application.It shows error-:

enter image description here

Requirement-:

How can i use .dll files generated by my c++ project into my c# application.


Solution

    1. The first error was because of the different Runtime Library in Project->Properties-> C/C++->Code Generation-> Runtime Library. The issue got resolved when for all the projects there was common Runtime Library.

    2. The second error was because of the mixing of different types of configuration and platform. I had my C# code in 64 bit format and C++ code in 32 bit, which was creating ambiguity.