Dynamics 365 CE Plugin Exception: System.Security.SecurityException: That assembly does not allow partially trusted callers.

Today I faced an in an existing plugin which was working earlier. During investigation, I found that this is caused by the “HttpUtility.UrlEncode(clientSecret)” as shown in below code snippet image

HTTPUtilitySecurityError

I found 2 ways to fix this issue

  1. User “System.Net.WebUtility.UrlEncode()” instead of “System.Web.HttpUtility.UrlEncode()”.
  2. Use “System.Uri.EscapeDataString() ” instead of “System.Web.HttpUtility.UrlEncode()”. as suggested in the this blog post by Nishant Rana.

Thanks-

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s