Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
5.9.5, 5.12.0, 5.12.1
-
None
-
-
d9a196a9a51d2a40ec7a64cacacab5608195be86 (qt/qtactiveqt/dev)
Description
When hosting a .Net control via QAxWidget, an exception is thrown in call to
m_spOleObject->Unadvise(m_dwOleObject);
Exception text: "COM object that has been separated from its underlying RCW cannot be used"
The reason of the exception is a previous call to
m_spOleObject->SetClientSite(0);
When .Net ActiveX wrapper (from .Net framework) performs that function, it completely destroys RCW for the client site:
internal void SetClientSite(UnsafeNativeMethods.IOleClientSite value) { ... if (UnsafeNativeMethods.IsComObject(clientSite)) { IntSecurity.UnmanagedCode.Assert(); try { Marshal.FinalReleaseComObject(clientSite); } finally { CodeAccessPermission.RevertAssert(); } } ... }
The call to FinalReleaseComObject completely destroys RCW (Runtime Callable Wrapper) for COM object.
Due to the fact that both IOleClientSite and IAdviseSink interfaces are represented by the same QAxClientSite object, the next call to Unadvise fails with an exception.
Proposed solution:
If there is no obvious reason why the order of the calls is as is, I propose to change the order:
m_spOleObject->Unadvise(m_dwOleObject); m_spOleObject->SetClientSite(0);
Thus the RCW won't be deleted.
Attachments
For Gerrit Dashboard: QTBUG-74096 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
255092,3 | Reverse the order of unitialization to avoid .Net exceptions | dev | qt/qtactiveqt | Status: MERGED | +2 | 0 |