2017-01-19 66 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

相關問題