當前位置: 首頁>>代碼示例>>C#>>正文


C# AppDomain.Load方法代碼示例

本文整理匯總了C#中AppDomain.Load方法的典型用法代碼示例。如果您正苦於以下問題:C# AppDomain.Load方法的具體用法?C# AppDomain.Load怎麽用?C# AppDomain.Load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AppDomain的用法示例。


在下文中一共展示了AppDomain.Load方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetRuntimeAssembly

        // TODO: Evidence is obsolete but I'm not sure if it can be removed yet as this can parse assemblies from
        // prior framework versions that do use it so we'll just suppress the warning for now.
#pragma warning disable 0618

        public System.Reflection.Assembly GetRuntimeAssembly(System.Security.Policy.Evidence evidence, AppDomain targetAppDomain)
        {
            System.Reflection.Assembly result = this.cachedRuntimeAssembly == null ? null : this.cachedRuntimeAssembly.Value;
            if(result == null || evidence != null || targetAppDomain != null)
            {
                lock(this)
                {
                    if(this.cachedRuntimeAssembly != null && evidence == null && targetAppDomain == null)
                        return this.cachedRuntimeAssembly.Value;
                    if(targetAppDomain == null)
                        targetAppDomain = AppDomain.CurrentDomain;
                    if(this.Location != null)
                    {
                        string name = this.StrongName;
                        System.Reflection.Assembly[] alreadyLoadedAssemblies = targetAppDomain.GetAssemblies();
                        if(alreadyLoadedAssemblies != null)
                            for(int i = 0, n = alreadyLoadedAssemblies.Length; i < n; i++)
                            {
                                System.Reflection.Assembly a = alreadyLoadedAssemblies[i];
                                if(a == null)
                                    continue;
                                if(a.FullName == name)
                                {
                                    result = a;
                                    break;
                                }
                            }
                        if(result == null)
                        {
                            if(evidence != null)
                                result = targetAppDomain.Load(this.GetAssemblyName(), evidence);
                            else
                                result = targetAppDomain.Load(this.GetAssemblyName());
                        }
                    }

                    if(result != null && evidence == null && targetAppDomain == AppDomain.CurrentDomain)
                    {
                        this.AddCachedAssembly(result);
                        this.cachedRuntimeAssembly = new CachedRuntimeAssembly(result);
                    }
                }
            }
            return result;
        }
開發者ID:modulexcite,項目名稱:SHFB-1,代碼行數:49,代碼來源:Nodes.cs


注:本文中的AppDomain.Load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。