GAC程序集加载Web App的自定义dll [英] GAC assemblies to load custom dll of Web App

查看:97
本文介绍了GAC程序集加载Web App的自定义dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

My application has a dll that will be invoked by .NET framework assemblies that reside in Global Assembly Cache. This perfectly works in a local machine.

我在Azure Web应用程序中遇到问题.在Azure Web应用程序中,我无法将程序集添加到GAC.因此,每当GAC dlls(System.dll,System.Xml.dll,.. etc)尝试加载我的程序集时,它都会抛出文件未找到异常而失败.但是在相同的过程中,我的程序集 已加载到不同的应用程序域/LM/2/...中,而不是加载到AppDomain"EE共享程序集存储库"中.

I am facing issue in Azure Web app. In Azure web apps, I couldn't add my assembly to GAC. So whenever the GAC dlls(System.dll,System.Xml.dll,..etc) tries to load my assembly it fails by throwing file not found exception. But in the same process my assembly got loaded into different Application domain /LM/2/... and not in AppDomain "EE Shared Assembly Repository".

  var appDomain = AppDomain.CreateDomain("New AppDomain", null, new AppDomainSetup
        {
            CachePath = AppDomain.CurrentDomain.SetupInformation.CachePath,
            ShadowCopyFiles = "true",
            LoaderOptimization = LoaderOptimization.SingleDomain //tried MultiDomain too
        });

By some code as above, I tried creating an AppDomain with different configurations and loaderoptimization sets and loaded the assembly into it, so that the System.dll can find and load my assembly. But that too dint work out.

推荐答案

只需突出显示来自的声明 文档,"GAC中的程序集(全局程序集缓存)-

Just to highlight the statement from this document, "Assemblies in the GAC (Global Assembly Cache) -This isn't supported. Consider copying required assemblies to the app's \bin folder. Custom .MSIs installed on the server (e.g. PDF generators, etc.) cannot be used."

请参阅文章

Refer the article File structure on azure to know the sets of files & dirs on Azure WebApp and ensure that you are using the right bit (32 vs 64) for your app.

 

David Ebbo在您的文章中提到 SO线程 ,您需要在AppDomainSetup对象上设置ApplicationBase和PrivateBinPath,这样它才能知道从何处加载程序集" .您可以在那里继续讨论以避免 重复.

As David Ebbo mentioned in your SO thread, "you need to set ApplicationBase and PrivateBinPath on the AppDomainSetup object so it knows where to load your assemblies from". You may continue your discussion there to avoid duplication.

 

您可能想知道,Windows现在可以在公共预览中使用WebApp中的服务器容器,并在Windows容器中部署应用程序 允许您安装自定义依赖项.示例包括必须安装到全局程序集缓存(GAC)中的自定义字体或组件库的安装.请注意,它仍然在 当前公共预览 ,并且只能用于评估目的.

You may wish to know, Windows Server Containers in WebApp are now available in public preview, with this, deploying an app within a Windows Container allows you to install custom dependencies. Examples include installation of custom fonts or component libraries which must be installed into the Global Assembly Cache (GAC). Note that it is still in public preview currently and can be used for evaluation purposes only.


这篇关于GAC程序集加载Web App的自定义dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆