G
Guest
Hello,
I have some legacy unmanaged C++ code in which I've introduced some managed
C++ using the new CLI feature of VS 2005. My managed C++ code invokes a
number of methods on a new C#class I've written. This C# class creates
additional managed objects and passes one of them back to the managed C++
code. I believe I have everything right to this point.
I need to briefly pass the managed object into unmanaged C++ code before
returning to managed C++ code. I want to make sure I do this correctly;
although the amount of time the object is passed into the unmanaged code is
very short, I don't want my managed object to get accidentally garbage
collection. I've looked at the MSDN documentation, and the suggestion seems
to be to use gcroot or GCHandle. However, in my case the managed object is
being instantiated in C#, not C++, so that's not an option. Is there any
other way I could be sure by object won't be garbage collected or relocated?
Thanks,
Notre
I have some legacy unmanaged C++ code in which I've introduced some managed
C++ using the new CLI feature of VS 2005. My managed C++ code invokes a
number of methods on a new C#class I've written. This C# class creates
additional managed objects and passes one of them back to the managed C++
code. I believe I have everything right to this point.
I need to briefly pass the managed object into unmanaged C++ code before
returning to managed C++ code. I want to make sure I do this correctly;
although the amount of time the object is passed into the unmanaged code is
very short, I don't want my managed object to get accidentally garbage
collection. I've looked at the MSDN documentation, and the suggestion seems
to be to use gcroot or GCHandle. However, in my case the managed object is
being instantiated in C#, not C++, so that's not an option. Is there any
other way I could be sure by object won't be garbage collected or relocated?
Thanks,
Notre