Treat WinMDs as having been loaded in the default ALC for AssemblyLoadContext.GetLoad...
authorJeremy Koritzinsky <jkoritzinsky@gmail.com>
Wed, 3 Apr 2019 11:21:16 +0000 (04:21 -0700)
committerJan Kotas <jkotas@microsoft.com>
Wed, 3 Apr 2019 11:21:16 +0000 (04:21 -0700)
src/vm/assemblynative.cpp

index 6cbb8af..a7d6863 100644 (file)
@@ -1331,7 +1331,14 @@ INT_PTR QCALLTYPE AssemblyNative::GetLoadContextForAssembly(QCall::AssemblyHandl
     // We should have a load context binder at this point.
     _ASSERTE(pOpaqueBinder != nullptr);
 
+    // the TPA binder uses the default ALC
+    // WinRT assemblies (bound using the WinRT binder) don't actually have an ALC,
+    // so treat them the same as if they were loaded into the TPA ALC in this case.
+#ifdef FEATURE_COMINTEROP
+    if (!AreSameBinderInstance(pTPABinder, pOpaqueBinder) && !AreSameBinderInstance(pCurDomain->GetWinRtBinder(), pOpaqueBinder))
+#else
     if (!AreSameBinderInstance(pTPABinder, pOpaqueBinder))
+#endif // FEATURE_COMINTEROP
     {
         // Only CLRPrivBinderAssemblyLoadContext instance contains the reference to its
         // corresponding managed instance.