{
GCX_PREEMP();
+ AssemblyLoaderAllocator* pBinderAssemblyLoaderAllocator = nullptr;
+
+ if (pBinderContext != nullptr)
+ {
+ pBinderContext->GetLoaderAllocator((LPVOID*)&pBinderAssemblyLoaderAllocator);
+ }
+
// Create a new LoaderAllocator if appropriate
if ((args->access & ASSEMBLY_ACCESS_COLLECT) != 0)
{
// atomically transfered by call to LoaderAllocator::ActivateManagedTracking().
pAssemblyLoaderAllocator->SetupManagedTracking(&args->loaderAllocator);
createdNewAssemblyLoaderAllocator = TRUE;
- }
- else
- {
- AssemblyLoaderAllocator* pAssemblyLoaderAllocator = nullptr;
- if (pBinderContext != nullptr)
+ if(pBinderAssemblyLoaderAllocator != nullptr)
{
- pBinderContext->GetLoaderAllocator((LPVOID*)&pAssemblyLoaderAllocator);
+ pAssemblyLoaderAllocator->EnsureReference(pBinderAssemblyLoaderAllocator);
}
-
- pLoaderAllocator = pAssemblyLoaderAllocator == nullptr ? pDomain->GetLoaderAllocator() : pAssemblyLoaderAllocator;
+ }
+ else
+ {
+ pLoaderAllocator = pBinderAssemblyLoaderAllocator == nullptr ? pDomain->GetLoaderAllocator() : pBinderAssemblyLoaderAllocator;
}
if (!createdNewAssemblyLoaderAllocator)