Skip to content

Commit

Permalink
Handle SPC in GetLoadContext
Browse files Browse the repository at this point in the history
GetBindingContext() returns NULL for System.Private.CoreLib.  Add support
for this special case.
  • Loading branch information
sdmaclea committed Feb 5, 2019
1 parent 5ede2e7 commit 7e20b6f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/vm/assemblynative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,13 +1302,22 @@ INT_PTR QCALLTYPE AssemblyNative::GetLoadContextForAssembly(QCall::AssemblyHandl
// actual ICLRPrivBinder instance in which the assembly was loaded.
PTR_ICLRPrivBinder pBindingContext = pPEAssembly->GetBindingContext();
UINT_PTR assemblyBinderID = 0;
IfFailThrow(pBindingContext->GetBinderID(&assemblyBinderID));

// If the assembly was bound using the TPA binder,
// then we will return the reference to "Default" binder from the managed implementation when this QCall returns.
//
// See earlier comment about "Default" binder for additional context.
pOpaqueBinder = reinterpret_cast<ICLRPrivBinder *>(assemblyBinderID);
if (pBindingContext)
{
IfFailThrow(pBindingContext->GetBinderID(&assemblyBinderID));

// If the assembly was bound using the TPA binder,
// then we will return the reference to "Default" binder from the managed implementation when this QCall returns.
//
// See earlier comment about "Default" binder for additional context.
pOpaqueBinder = reinterpret_cast<ICLRPrivBinder *>(assemblyBinderID);
}
else
{
// GetBindingContext() returns NULL for System.Private.CoreLib
pOpaqueBinder = pTPABinder;
}

// We should have a load context binder at this point.
_ASSERTE(pOpaqueBinder != nullptr);
Expand Down

0 comments on commit 7e20b6f

Please sign in to comment.