简体   繁体   中英

crm dynamics online, pass custom url parameter to plugin

I want to create a plugin that reads a custom parameter from the url. I found this piece of code

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

When I tried implementing it for this call

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

I got the following error:

System.Security.SecurityException: That assembly does not allow partially trusted callers.

I tried to resolve this by applying an attribute to the assembly, shown in this post:

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

I was not sure what security permissions where needed for httpcontext ie FileIOPermission or PrincipalPermission. So I ended up using the SecurityPermission option.

However this did not resolve the issue. Any ideas will be appreciated. thanks in advance.

You are probably getting that error because your plugin is running within the sandbox.

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.

You could try moving your plugin outside of the sandbox - look for isolation mode during plugin registration.

However, I would suggest taking a different approach entirely - such as reading data from record fields. Reading from the query string is a bit unusual and the query string format has been known to change between CRM versions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM