Don't understand what's required in order to use unmgd c++ class in c# app - help?
-
Hi all, I've got the source code and compiled binary for a c++ class library, and I'd like to be able to instantiate & use the class in a c# application. What's the simplest way to do this? I've looked up resources, but they all appear to me more complicated than my basic level of understanding of MS C++ will allow to be helpful to me. Can someone point me to a very simple recipe (and hopefully simple explanation too) on how to turn this unmanaged class into one which c# can use? Also, will there be issues about "return data type matching" between c++ and c#? Thanks, cdj
-
Hi all, I've got the source code and compiled binary for a c++ class library, and I'd like to be able to instantiate & use the class in a c# application. What's the simplest way to do this? I've looked up resources, but they all appear to me more complicated than my basic level of understanding of MS C++ will allow to be helpful to me. Can someone point me to a very simple recipe (and hopefully simple explanation too) on how to turn this unmanaged class into one which c# can use? Also, will there be issues about "return data type matching" between c++ and c#? Thanks, cdj
-
Hi all, I've got the source code and compiled binary for a c++ class library, and I'd like to be able to instantiate & use the class in a c# application. What's the simplest way to do this? I've looked up resources, but they all appear to me more complicated than my basic level of understanding of MS C++ will allow to be helpful to me. Can someone point me to a very simple recipe (and hopefully simple explanation too) on how to turn this unmanaged class into one which c# can use? Also, will there be issues about "return data type matching" between c++ and c#? Thanks, cdj
sherifffruitfly wrote:
I've got the source code and compiled binary for a c++ class library, and I'd like to be able to instantiate & use the class in a c# application.
Then you need to compile it into a DLL, either COM or just standard. You can in both cases easily import your DLL into C# ( the plain dll via a p/invoke signature for each method you want to call ), but the COM way allows you to create class instances, p/invoke does not.
sherifffruitfly wrote:
Also, will there be issues about "return data type matching" between c++ and c#?
If you use COM, then the IDE will fix that for you, if you use a dll, then you need to work it out for each method, for both return values, and values going in. By far the most intelligent thing to do is to make your code managed, so you can create class instances and fully interact with them in C#.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
sherifffruitfly wrote:
I've got the source code and compiled binary for a c++ class library, and I'd like to be able to instantiate & use the class in a c# application.
Then you need to compile it into a DLL, either COM or just standard. You can in both cases easily import your DLL into C# ( the plain dll via a p/invoke signature for each method you want to call ), but the COM way allows you to create class instances, p/invoke does not.
sherifffruitfly wrote:
Also, will there be issues about "return data type matching" between c++ and c#?
If you use COM, then the IDE will fix that for you, if you use a dll, then you need to work it out for each method, for both return values, and values going in. By far the most intelligent thing to do is to make your code managed, so you can create class instances and fully interact with them in C#.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
I want instances, so I guess the COM compilation is what would be helpful. I'll look up how to do that. The way I did it, I believe it's "just standard": #ifndef DllExport #define DllExport __declspec( dllexport ) #endif ... class DllExport {...} Thanks for the suggestions!
-
We'll see how it goes here; if necessary, I will. Thanks!
-
We'll see how it goes here; if necessary, I will. Thanks!
Well the person I know would have an answer replied here so...cool! Good luck! Mark
Mark Salsbery Microsoft MVP - Visual C++