What is the best online guide/tutorial to start with interop using C# and C++/CLI ? I’m looking for a good guide in passing structures made in C# to C++/CLI. Many of the tutorials I have seen do not cover passing custom structures made in C# to C++/CLI.
Any suggestions ?
Thanks.
The reason you don’t find many tutorials is that there is really nothing to it. You pass the managed structure from C# to C++/CLI the same way as you would to another C# class/method
say you had structure in C#:
You would write a method in C++/CLI that looked like this:
So, a couple of notes…
code to get your C# reference
You need to be careful not to create circular references, so you may want to have TheStruct defined in C++/CLI in which case it would
look like:
public ref struct TheStruct
{
public:
int i;
String ^str;
}
Easy enought?