2017-01-19 64 views
3

我想创建一个从url读取自定义参数的插件。我发现这个 一段代码crm dynamics online,将自定义url参数传递给插件

https://blogs.msdn.microsoft.com/madenwal/2011/04/15/retrieving-querystring-paramaters-in-a-crm-plug-in/

当我试图实现它本次呼叫

var reference = HttpContext.Current.Request.QueryString["parameter_reference"] 

我得到了以下错误:

System.Security.SecurityException:该程序集不不允许部分信任的来电者。

我试图用一个属性的组件,在这个岗位显示出解决此问题:

https://support.microsoft.com/en-us/help/839300/how-to-use-the-allowpartiallytrustedcallers-attribute-to-call-an-assembly-that-has-a-strong-name-from-a-web-page-by-using-visual-c-.net,-visual-c-2005-or-later-versions

我不知道什么地方需要的HttpContext即FileIOPermission的或安全的PrincipalPermission权限。所以我最终使用了SecurityPermission选项。

但是这并没有解决问题。任何想法将不胜感激。 在此先感谢。

回答

2

您可能会因为您的插件在沙箱中运行而出现该错误。

Plug-in isolation, trusts, and statistics

Microsoft Dynamics 365 (online & on-premises) support the execution of plug-ins and custom workflow activities in an isolated environment. In this isolated environment, also known as a sandbox, a plug-in or custom activity can make use of the full power of the Microsoft Dynamics 365 SDK to access the organization web service. Access to the file system, system event log, certain network protocols, registry, and more is prevented in the sandbox.

你可以尝试移动你的插件的沙箱之外 - 插件注册过程中寻找隔离模式。

但是,我会建议完全采用不同的方法 - 例如从记录字段中读取数据。从查询字符串中读取有点不寻常,并且已知查询字符串格式在CRM版本之间改变。

+0

感谢您的回复。我们的环境在线,因此无法将插件移出沙盒。这个场景有点不寻常,但是我最终实现了一个使用记录ID作为参考(而不是自定义参数)来查询外部服务的解决方案。 – noobie

相关问题