Reference managed type members in an unmanaged class by using the "gcroot<>" template. This provides a wrapper around the GCHandle class.
Look at this msdn explanantion
Also there is this article on codeproject
Look at this msdn explanantion
Also there is this article on codeproject
gcrootPinning in C++/CLI. Do this using the pin_ptr keyword. This prevents the managed object from being moved around in memory by the garbage collectorstr; str = gcnew String("hello");
Object ^obj = gcnew MyClass(); pin_ptr pinned = obj;