C# Sytem.Reflection.Emit在Azure函数中建立XML客户端时出错
正在尝试从我的函数应用程序建立到第三方web服务的xmlrpc。它在localhost上运行良好,事实上,它在其他功能中也可以运行,但在发布到Azure时,我遇到以下错误:C# Sytem.Reflection.Emit在Azure函数中建立XML客户端时出错,c#,.net,azure,C#,.net,Azure,正在尝试从我的函数应用程序建立到第三方web服务的xmlrpc。它在localhost上运行良好,事实上,它在其他功能中也可以运行,但在发布到Azure时,我遇到以下错误: System.MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, Sy
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>();
我已经手动将System.Reflection.Emit包添加到解决方案中,试图修复它,但没有成功。同样的代码在Azure中的其他应用程序中运行良好。该应用程序正在运行.Net framework 4.6.1。这是一个问题,当旧版本的DLL仍然在附近徘徊时,可能会出现此问题。确保部署了最新的程序集,并且没有重复的旧程序集隐藏在某些文件夹中。您最好删除每个生成项(
Clean Build
)并Rebuild
/重新部署整个解决方案
尤其是,确保旧版本不在文件中。
这有助于解决问题。我和你面临的问题是一样的。 我找到的解决方案是,我使用的是asp.net核心框架,所以我必须将其更改为NET4.5框架。就这些。 问题解决了。
因此,您可以尝试一下。接受作为解决方案,因为即使建议的特定步骤没有解决问题,但我确实认为冲突的DLL才是问题所在。最后,我完全重新构建了解决方案,消除了对其他项目的所有依赖,最终它成功了。还感谢您为我指明了GAC工具的方向。那真的很有用。
using CookComputing.XmlRpc;
using System;
namespace App.Core.Helpers.Service
{
[XmlRpcUrl("https://some.url")]
public interface IServiceClient : IXmlRpcProxy
// methods
}