
Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Thanks, this actually proved to be opportune as we use a great deal of event handling code with our objects. Specifically we integrate with our third party app by reacting to events that it raises.
Cheers,
Bob
nntp://msnews.microsoft.com/microsoft.public.dotnet.framework.interop/<OLzrKotAFHA.2584@TK2MSFTNGP09.phx.gbl>
Peter,
>828980 BUG: COM objects with events are not correctly released by Garbage
>http://support.microsoft.com/?id=828980
This article doesn't appear to be public (yet).
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
[microsoft.public.dotnet.framework.interop]
"Peter Huang" [MSFT] - 26 Jan 2005 05:30 GMT
Hi Bob,
Yes, it seems that article has not been published and it is still under
test.
So as a suggestion, I think we would better release the Com Event handle
before we set the object to null.
e.g.
ComServer.CMyClass MC = new ComServer.CMyClassClass();
MC.Close += new ComServer._IMyClassEvents_CloseEventHandler(MC_Close);
MC.Close -= new ComServer._IMyClassEvents_CloseEventHandler(MC_Close);
MC = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
Hope this helps.
Best regards,
Perter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Robert Porter - 26 Jan 2005 22:40 GMT
Thanks Peter,
I will give that a try, makes sense so I should be able to implement it in my environment.
Bob
nntp://msnews.microsoft.com/microsoft.public.dotnet.framework.interop/<T#b5tg2AFHA.3152@cpmsftngxa10.phx.gbl>
Hi Bob,
Yes, it seems that article has not been published and it is still under
test.
So as a suggestion, I think we would better release the Com Event handle
before we set the object to null.
e.g.
ComServer.CMyClass MC = new ComServer.CMyClassClass();
MC.Close += new ComServer._IMyClassEvents_CloseEventHandler(MC_Close);
MC.Close -= new ComServer._IMyClassEvents_CloseEventHandler(MC_Close);
MC = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
Hope this helps.
Best regards,
Perter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
[microsoft.public.dotnet.framework.interop]
"Peter Huang" [MSFT] - 27 Jan 2005 02:24 GMT
Hi
I am glad that my suggestion will help you.
Best regards,
Perter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.