WCF System.TypeLoadException:访问被拒绝:

问题描述

我有一个自托管的 WCF 服务器,它在我的开发机器上运行良好。

但是,当我在 Windows 2012 服务器上运行它时,出现此错误

System.TypeLoadException: Access is denied: 'Castle.DynamicProxy.Internal.CompositionInvocation'.

当我将 4.5 服务迁移到 .net 4.8 时出现此错误 有什么线索吗?

添加:这是失败的起始代码

var binding = new BasicHttpBinding
        {
            Security =
            {
                Mode = BasicHttpSecurityMode.Transport
            },MaxReceivedMessageSize = int.MaxValue,MaxBufferPoolSize = int.MaxValue,OpenTimeout = TimeSpan.FromMinutes(1),CloseTimeout = TimeSpan.FromMinutes(1),SendTimeout = TimeSpan.FromMinutes(20),ReceiveTimeout = TimeSpan.FromMinutes(20),};
        var endpointAddress = new EndpointAddress(Configuration.PmsUrl);
        var client = new WebServiceRouterSoapClient(binding,endpointAddress);
        client.Endpoint.Behaviors.Add(new LoggingEndpointBehavIoUr());

        try
        {
            var response = action(client);
            client.Close();
            if(response.ExceptionCode > 0)
            {
                throw new Exception($"Exception {response.ExceptionCode} - {response.ExceptionDescription}");
            }
        }
        catch(Exception ex)
        {
            Log.GetLog().Error(ex);
            client.Abort();
        }

谢谢。乔纳森

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)