Adam Mitz [MSFT] wrote:
Sorry I misread your original post. It seems the 2nd level of
indirection must be a __nogc* pointer. This compiles:
__gc class ImgPtr{
public:
System::Drawing::Image* __nogc* ppBmp;
};
int _tmain(){
ImgPtr* iptr = new ImgPtr;
*(iptr->ppBmp) = new System::Drawing::Bitmap(640, 480);
}
Of course, keep in mind that __nogc pointers to managed objects or other
__gc pointers is inherently dangerous. In order to ensure that the __nogc
pointer points to a valid object, the object it points to must be pinned. As
pinning can only be done by __pin pointers, which can only exist on the
stack, it is a really bad idea to store a __nogc pointer that points to a
managed object in a class or someother static or dynamic storage.
Rather than looking for a way to store a pointer to a pointer to a managed
class, I'd step back and ask why you want to do that? To do this correctly
with the CLR is a lot of work, and it will likely be better to just
rearchitect the program to avoid this necessity.
Cheerio!
--
Brandon Bray Visual C++ Compiler
This posting is provided AS IS with no warranties, and confers no rights.