制作GAC程序集以加载自定义程序集

时间:2018-09-25 11:08:48

标签: c# .net azure azure-web-sites .net-assembly

我的应用程序有一个dll,该dll将由驻留在Global Assembly Cache中的.NET Framework程序集调用。这完全可以在本地计算机上工作。

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

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

通过上面的一些代码,我尝试使用不同的配置和加载程序优化集创建一个AppDomain并将程序集加载到其中,以便System.dll可以找到并加载我的程序集。但这太好了。

我如何使我的程序集(存在于%home%\ wwwroot \ bin中)被加载到GAC中存在的dll中??

1 个答案:

答案 0 :(得分:1)

我相信您需要在cat /proc/partitions 对象上设置ApplicationBasePrivateBinPath,以便它知道从何处加载程序集。