微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 从CRM沙盒插件调用WCF(使用生成的客户端)抛出System.Security.SecurityException

上下文

我正在使用生成的客户端从CRM插件调用WCF服务. (System.ServiceModel.ClientBase< T>)CRM插件必须在沙箱隔离模式下工作. WCF客户端是从纯wsdl和xsd生成的.它似乎正在使用Xml序列化,因此不涉及任何反射.

插件执行抛出:

System.Security.SecurityException: Request for the permission of type ‘System.Security.Permissions.SecurityPermission,

在堆栈跟踪中,它似乎来自WCF客户端实现的核心:

Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation,ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object[] ins,Object[] outs,TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)
at Microsoft.Crm.SandBox.ISandBoxHost.ExecuteCustomWorkflowActivityAndReturnTraceInfo(SandBoxCallInfo callInfo,SandBoxCustomActivityExecutionContext requestContext,Guid pluginAssemblyId,Int32 sourceHash,String assemblyName,Guid pluginTypeId,String pluginTypeName,String assemblyContents,Boolean returnTraceInfo)
at Microsoft.Crm.SandBox.SandBoxCustomActivity.Execute(SandBoxClient client,SandBoxCallTracker callTracker,IExecutionContext requestContext,Boolean returnTraceInfo)
at Microsoft.Crm.SandBox.SandBoxCodeUnit.Execute(IExecutionContext context)

声明是否正确我们不能在沙箱隔离模式和CRM Online中使用WCF客户端? (或者我错过了什么……?)

如果是这样,解决方法是什么?我们是否必须重新实现所有消息呈现和解析?

解决方法

您可以在visual studio生成的标准“服务引用”(或旧的Web引用)不会在沙盒模式下工作.它使用Microsoft序列化程序(来自System.Runtime.Serialization),认情况下,沙箱中不支持任何未在GAC中注册的类.

http://www.instantquick.com/index.php/serialization-in-sandbox-solutions?c=elumenotion-blog-archive/random-whatnot

据我所知,没有快速解决方案.该链接提供了2种可能的替代解决方案,但两种解决方案都不能直接与服

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐