【问题标题】:Making GAC assembly to load custom assembly制作 GAC 程序集以加载自定义程序集
【发布时间】:2018-09-25 11:08:48
【问题描述】:

我的应用程序有一个 dll,它将由驻留在全局程序集缓存中的 .NET 框架程序集调用。这在本地机器上完美运行。

我在 Azure Web 应用程序中遇到问题。在 Azure Web 应用程序中,我无法将我的程序集添加到 GAC。因此,每当 GAC dlls(System.dll,System.Xml.dll,..etc) 尝试加载我的程序集时,它都会通过抛出文件未找到异常而失败。但在同一个过程中,我的程序集被加载到不同的应用程序域 /LM/2/... 而不是 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
        });

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

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

【问题讨论】:

    标签: c# .net azure azure-web-app-service .net-assembly


    【解决方案1】:

    我相信您需要在AppDomainSetup 对象上设置ApplicationBasePrivateBinPath,以便它知道从哪里加载您的程序集。

    【讨论】:

    • appdomain 正在加载我的程序集。但这里的问题是 GAC 中的程序集找不到我的 dll。 (即)当我的汇编代码在 System.Web.dll 和 System.Data.dll 中执行时,我收到 filenotfound 异常说找不到我的 dll。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多