I need to use a DLL coded in C++ in a C# application, there is a method in the DLL with receives a object declared in the C++ and I don’t know how to parse a equivalent object maded in C# to the function of the DLL
Can someone help me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will need to use the System.Runtime.InteropServices namespace with Platform Invoke if the c++ code is not managed or COM. You will need to define the structure in your C# application and pass an object of whatever type your structure is to the method you are using Platform Invoke on. To tell you anymore, I need to see some header files.
Here is a sample :
c++ header:
c# declarations:
Of course, it could get much more complicated but that is the general idea.
It can and may get really nasty when you have to worry about calling conventions and marshaling arrays. Regardless the world needs to see some code from you.