// ICLRPrivAssembly implements ICLRPrivBinder and thus, "is a" binder in a manner of semantics.
pParentAssemblyBinder = pParentPEAssembly->GetBindingContext();
- if (pParentAssemblyBinder == NULL)
- {
- if (pParentPEAssembly->IsDynamic())
- {
- // If the parent assembly is dynamically generated, then use its fallback load context
- // as the binder.
- pParentAssemblyBinder = pParentPEAssembly->GetFallbackLoadContextBinder();
- }
- }
}
if (GetPreferFallbackLoadContextBinder())
//
// 1) Domain Neutral assembly
// 2) Entrypoint assembly
- // 3) RefEmitted assembly
- // 4) AssemblyLoadContext.LoadFromAssemblyName
+ // 3) AssemblyLoadContext.LoadFromAssemblyName
//
// For (1) and (2), we will need to bind against the DefaultContext binder (aka TPA Binder). This happens
// below if we do not find the parent assembly binder.
//
- // For (3) and (4), fetch the fallback load context binder reference.
+ // For (3), fetch the fallback load context binder reference.
pParentAssemblyBinder = GetFallbackLoadContextBinderForRequestingAssembly();
}
// The Binding Context can be null or an overridden TPA context
if (pBindingContext == NULL)
{
- pBindingContext = nullptr;
-
- // If the assembly does not have a binder associated with it explicitly, then check if it is
- // a dynamic assembly, or not, since they can have a fallback load context associated with them.
- if (pManifestFile->IsDynamic())
- {
- pBindingContext = pManifestFile->GetFallbackLoadContextBinder();
- }
- }
-
- // If we do not have any binder associated, then return to the default resolution mechanism.
- if (pBindingContext == nullptr)
- {
+ // If we do not have any binder associated, then return to the default resolution mechanism.
return NULL;
}
PTR_ICLRPrivBinder pBindingContext = NULL;
- // Mscorlib is always bound in context of the TPA Binder. However, since it gets loaded and published
- // during EEStartup *before* TPAbinder is initialized, we dont have a binding context to publish against.
+ // CoreLibrary is always bound in context of the TPA Binder. However, since it gets loaded and published
+ // during EEStartup *before* DefaultContext Binder (aka TPAbinder) is initialized, we dont have a binding context to publish against.
// Thus, we will always return NULL for its binding context.
if (!IsSystem())
{
pBindingContext = dac_cast<PTR_ICLRPrivBinder>(GetHostAssembly());
+ if (!pBindingContext)
+ {
+ // If we do not have any binding context, check if we are dealing with
+ // a dynamically emitted assembly and if so, use its fallback load context
+ // binder reference.
+ if (IsDynamic())
+ {
+ pBindingContext = GetFallbackLoadContextBinder();
+ }
+ }
}
return pBindingContext;
// To enable this, we maintain a concept of "Fallback LoadContext", which will be set to the Binder of the
// assembly that created the dynamic assembly. If the creator assembly is dynamic itself, then its fallback
// load context would be propagated to the assembly being dynamically generated.
- ICLRPrivBinder *m_pFallbackLoadContextBinder;
+ PTR_ICLRPrivBinder m_pFallbackLoadContextBinder;
protected:
bool CanUseWithBindingCache()
{ LIMITED_METHOD_CONTRACT; return !HasHostAssembly(); }
- void SetFallbackLoadContextBinder(ICLRPrivBinder *pFallbackLoadContextBinder)
+ void SetFallbackLoadContextBinder(PTR_ICLRPrivBinder pFallbackLoadContextBinder)
{
LIMITED_METHOD_CONTRACT;
m_pFallbackLoadContextBinder = pFallbackLoadContextBinder;
}
- ICLRPrivBinder *GetFallbackLoadContextBinder()
+ PTR_ICLRPrivBinder GetFallbackLoadContextBinder()
{
LIMITED_METHOD_CONTRACT;