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 i.e 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With