【问题标题】:Sytem.Reflection.Emit error when establishing XML client in Azure Function在 Azure Function 中建立 XML 客户端时发生 System.Reflection.Emit 错误
【发布时间】:2019-11-16 15:48:24
【问题描述】:

尝试从我的函数应用程序建立一个到第三方 Web 服务的 xmlrpc。它在本地主机上运行良好,实际上,它在其他功能中也能运行,但是当发布到 Azure 时出现此错误:

 System.MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.
   at CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf, String assemblyName, String moduleName, String typeName, AssemblyBuilderAccess access)
   at CookComputing.XmlRpc.XmlRpcProxyGen.Create(Type itf)
   at CookComputing.XmlRpc.XmlRpcProxyGen.Create[T]()

在这一行失败了:

 _serviceClient = XmlRpcProxyGen.Create<IServiceClient>();

IServiceClient 是一个如下所示的接口:

using CookComputing.XmlRpc;
using System;

namespace App.Core.Helpers.Service
{
    [XmlRpcUrl("https://some.url")]
    public interface IServiceClient : IXmlRpcProxy

// methods
}

我已手动将 System.Reflection.Emit 包添加到解决方案中以尝试修复它,但没有任何乐趣。完全相同的代码在我们在 Azure 中的其他应用程序中运行良好。该应用正在运行 .Net 框架 4.6.1。

【问题讨论】:

    标签: c# .net azure


    【解决方案1】:

    当有一个旧版本的 DLL 仍然存在于某个地方时,可能会出现此问题。确保部署了最新的程序集,并且没有重复的旧程序集隐藏在某些文件夹中。您最好的选择是删除所有已构建的项目 (Clean Build) 和 Rebuild/重新部署整个解决方案。

    特别是,请确保旧版本不在GAC 中。 这可以帮助Remove an Assembly from the Global Assembly Cache

    【讨论】:

    • 接受作为解决方案,因为即使建议的具体步骤没有解决问题,我相信冲突的 dll 是问题所在。最后,我完全重建了解决方案,删除了对其他项目的所有依赖项,终于成功了。还要感谢您为我指明该 GAC 工具的方向。这真的很有用。
    【解决方案2】:

    我遇到了和你一样的问题。 我找到的解决方案是,我使用的是 asp.net 核心框架,所以我必须将其更改为 net 4.5 框架。就这样。 问题解决了。 所以你可以试试。

    【讨论】:

      猜你喜欢
      • 2021-02-24
      • 1970-01-01
      • 1970-01-01
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多