接上一篇,Core CLR利用 LoadDomainAssembly加载程序集,并且运用了.net 或者Java里面的全局注入形式来操作程序集的生成和运作具体代码如下:Java/Python/Go/.Net讨论交流群:676817308
1.首先会获取到 AppDomain的实例
2.获取到ICLRPrivBinder的实例,这个ICLRPrivBinder可以利用assemblyspec.SetHostBinder来设置,然后通过 ICLRPrivBinder * pBinder = GetHostBinder();默认的是为空的。
3.假如clrprivbinder的实例为空他会通过代码: pBinder = GetBindingContextFromParentAssembly(pDomain);来获取 clrprivbinder 的实例,GetBindingContextFromParentAssembly(pDomain);源码如下
ICLRPrivBinder* AssemblySpec::GetBindingContextFromParentAssembly(AppDomain *pDomain)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(pDomain != NULL);
}
CONTRACTL_END;
ICLRPrivBinder *pParentAssemblyBinder = NULL; //初始值为NULL
DomainAssembly *pParentDomainAssembly = GetParentAssembly(); //获取到父类的domainaasembly,这个默认的是为空的,可以通过SetParentAssembly来设置其值
if(pP