sherifffruitfly wrote:
Hi,
I want to use a c++ class in my c# application. Are there any clear
step-by-step tutorials on an easy way to achieve this? All I've been
able to find are relatively complicated discussions about managed
extensions and what-not. I also saw someone make the suggestion that
they compile their c++ class as a COM component, but I have no idea
how to do this either. I'm just looking for any straightforward way to
make my c++ class available to c#.
In general, there is no straightforward way - unless your C++ class happens
to already be a COM class. For any other case, you need to learn and
understand the intricacies of native/managed interop. There are a myriad of
possibilities, depending on the class and how it's used - so you're unlikely
to find a step by step tutorial that tells you exactly what you need to
know.
If you can provide more information about the C++ class, I or others can
give you more detailed help.
What does the interface of the C++ class look like? How is it used? How is
it's lifetime managed? Does it make callbacks from arbitrary threads?
These and potentially many other questions may influence your options for
using this class from C#.
-cd