Currently in CoreCLR, We don't propagate managed exception from Managed->Native->Managed correctly for non-appx case--- if you throw a managed exception, then during M->N, the managed exception is stored in thread, later during N->M, we will try to fetch this stored exception if it is managed exception by checking IsManagedObject()
The logical for IsManagedObject should be just check its IUnknown slots first no matter whether it is appx or not; If doesn't match, try to QI IManagedObject.
[tfs-changeset: 1486094]
}
CONTRACTL_END;
- if (AppX::IsAppXProcess())
+ //Check based on IUnknown slots, i.e. we'll see whether the IP maps to a CCW.
+ if (MapIUnknownToWrapper(pIUnknown) != NULL)
{
- //In AppX we don't support IManagedObject so we'll do the check based on
- //IUnknown slots, i.e. we'll see whether the IP maps to a CCW.
- if (MapIUnknownToWrapper(pIUnknown) != NULL)
- {
- // We found an existing CCW hence this is a managed exception.
- return TRUE;
- }
+ // We found an existing CCW hence this is a managed exception.
+ return TRUE;
}
- else
+
+ // QI IManagedObject. Note AppX doesn't support IManagedObject
+ if (!AppX::IsAppXProcess())
{
SafeComHolder<IManagedObject> pManagedObject = NULL;
HRESULT hrLocal = SafeQueryInterface(pIUnknown, IID_IManagedObject, (IUnknown**)&pManagedObject);