Core CLR Host 源码分析(三)

本文继续深入分析Core CLR的源码,重点探讨LoadDomainAssembly如何加载程序集,以及.NET和Java中全局注入的实现方式。内容包括获取AppDomain实例、ICLRPrivBinder的作用,以及在clrprivbinder实例为空时如何通过GetBindingContextFromParentAssembly进行处理。
摘要由CSDN通过智能技术生成

接上一篇,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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值