Hi,
please pardon me if I sound stupid. I want to check the status of the
GChandle to see if a previous call to Alloc is successful, or whether it
has been called before hand, before I call the Free function. I tried
the following code,
GCHandle gch;
gch=GCHandle::Alloc(Mydelegate); <== How do I check if this is successful?
gch.Free();
Refering to MSDN, it mentioned only what happens when Alloc is
successful, not when Alloc failed. in C++/CLI, I tried
if (gch.IsAllocated)
gch.Free();
but it gave me an "Invalid Operation exception, handle not initialized"
when I purposely omit the alloc statement. So, how should I handle
this? .NET can't be this stupid that the object does not know its own
status. Can someone help me? the new MSDN gives me all the info except
the one I need.