本文介绍了如何修复WCF错误:请求类型为'System.Security.Permissions.EnvironmentPermission的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows服务中托管netTcpBinding WCF服务器.我能够通过我自己的客户端成功连接到其远程呼叫,因此我知道它运行良好.

但是,当我尝试通过第三方解决方案通过.NET插件连接到同一服务时,会生成类型为'System.Security.Permissions.EnvironmentPermission'的权限请求例外.

我从第三方应用程序加载的客户端插件正在执行以下操作:

        EndpointAddress endpointAdress = new EndpointAddress("net.tcp://localhost:2001/MyWCFServer/Server");

        NetTcpBinding binding1 = new NetTcpBinding();

        CTraderClient  _client = new CTraderClient(new InstanceContext(this), binding1, endpointAdress);

         _client.RegisterBotInstance("GBPUSD", 30);

其中RegisterBotInstance是对WCF服务器公开的远程方法的调用.

当我调用此远程方法_client.RegisterBotInstance("GBPUSD",30)时,会引发以下异常:

其他信息:请求"System.Security.Permissions.EnvironmentPermission,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089"类型的权限失败.

操作:System.Security.Permissions.SecurityAction.Demand

有人能想到解决此问题的方法吗?

顺便说一下,第三方应用程序是cAlgo,以防万一.

该第三方软件似乎存在一些信任问题.

解决方案

解决方案是将其添加到插件标头中:

AccessRights = AccessRights.FullAccess

I am hosting a netTcpBinding WCF server in a Windows service. I am able to successfully connect to its remote calls via my own client without issue, so I know that it works well.

However, I generate the exception Request for the permission of type 'System.Security.Permissions.EnvironmentPermission when I attempt to connect to the same service via a .NET plugin fom a third party solution.

My client plugin loaded from the third party application is doing the following:

        EndpointAddress endpointAdress = new EndpointAddress("net.tcp://localhost:2001/MyWCFServer/Server");

        NetTcpBinding binding1 = new NetTcpBinding();

        CTraderClient  _client = new CTraderClient(new InstanceContext(this), binding1, endpointAdress);

         _client.RegisterBotInstance("GBPUSD", 30);

where RegisterBotInstance is a call to the remote method exposed by the WCF server.

When I call this remote method _client.RegisterBotInstance("GBPUSD", 30);the following exception is raised:

Additional information: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Action: System.Security.Permissions.SecurityAction.Demand

Can anyone think of a fix to this?

By the way, the third party application is cAlgo in case this is of any use.

It seems that this third party software has some trust issues.

解决方案

The solution to this is to add this to the plugin header:

AccessRights = AccessRights.FullAccess

这篇关于如何修复WCF错误:请求类型为'System.Security.Permissions.EnvironmentPermission的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 17:52