> Hi.
>
[quoted text clipped - 16 lines]
> the non-managed and managed classes, but that also did not work. Could
> anyone please give me a hand with this (rather common?) problem?
> Talking about VS 2003 which is the latest official product out there,
> you can place unmanaged pointers in managed classes (and create
> unmanaged objects using 'new' in constructor and 'delete' in the
> destructor), and place managed pointers ("handles" in upcoming VS 2005)
> in unmanaged classes by using gcroot.
Thank you all for your responses. I swear I couldn't find any mention of
gcroot (at least not one that rang a bell) while I was searching for a
solution. Or maybe it was just my exhaustion.
Anyway, I ended up using a kludge: I built a ref class to act as a
mediator. That mediator uses a static member variable to hold a handle
to the managed object I was interested in and a static member variable
to allow my non-managed entity to indirectly access it. That worked, but
I will look up "gcroot" as it seems like a cleaner solution.
Cheers,

Signature
Ney André de Mello Zunino
Ioannis Vranos - 06 May 2005 18:31 GMT
> Thank you all for your responses. I swear I couldn't find any mention of
> gcroot (at least not one that rang a bell) while I was searching for a
[quoted text clipped - 5 lines]
> to allow my non-managed entity to indirectly access it. That worked, but
> I will look up "gcroot" as it seems like a cleaner solution.
An example:
#include <vector>
// For gcroot
#include <vcclr.h>
using namespace std;
using namespace System;
vector< gcroot<Managed_Class *> > vec;
like
vector< gcroot<Button *> >vec;
This is with "managed extensions" syntax (managed pointers replaced by "handles" in VD 2005).
However in VS 2005, there will be "STL .NET" (an STL implementation working with managed
objects), making gcroot redundant when using that.