Browser control in separate AppDomain crash on exit
- From: "Clive Dixon" <clived.cutthespam@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 4 Apr 2005 15:28:38 +0100
I have a form with a browser control (AxInterop.ShDocVw.AxWebBrowser). The
form is opened in a separate AppDomain. I find that when I close down my app
(unmanaged app calling via interop into assembly which creates separate
AppDomain and shows form), I get an exception thrown or crash generated
(release or debug build respectively), the exception being a
NullReferenceException thrown from AxHost.ConnectionPointCookie.Disconnect.
If I manually Dispose the AxHost object after I have closed the form, then
the problem vanishes.
The AxHost.ConnectionPointCookie.Disconnect is being called via
AxHost.Finalize, presumably via garbage collection when the AppDomain is
unloaded. The difference I notice between 'normal' and 'manual Dispose'
scenarios is that System.__ComObject.m_wrap is null and non-null
respectively in the two cases.
It appears as though the AppDomain unload is blowing away the COM object
before calling garbage collection so that the Marshal.ReleaseComObject in
ConnectionPointCookie.Disconnect barfs. I understand that unloading an
AppDomain releases COM objects loaded into that AppDomain, but should it be
working at cross-purposes like this? Is this a .NET bug?
.
- Follow-Ups:
- Prev by Date: Re: How to create type that represents pointer to a struct?
- Next by Date: preserving pivot table state
- Previous by thread: C# NewBie : Marshalling question
- Next by thread: Re: Browser control in separate AppDomain crash on exit
- Index(es):
Relevant Pages
|