Question

I have created a plugin and it was registered successfully (Sandbox Isolation Mode).

Inside Plugin execution, I want to create an object of OrganizationServiceProxy, which is using another CRM details. Using the code below:

Uri oUri = new Uri("https://yourorg.api.crm5.dynamics.com/XRMServices/2011/Organization.svc");
            //** Your client credentials 
            ClientCredentials clientCredentials = new ClientCredentials();
            clientCredentials.UserName.UserName = "YourAccount.onmicrosoft.com";
            clientCredentials.UserName.Password = "YourAdminPassword";

            //Create your Organization Service Proxy
            OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(
                oUri,
                null,
                clientCredentials,
                null);

I am getting Security Exception:

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Searched for the same issue but not working, Please suggest.

Was it helpful?

Solution 2

I have searched a lot but the plugin is registered in sandbox mode so it, doesn't allow to access external services.

Found the best way to use it.

Created Azure web service and use the service in Plugin, it works.

OTHER TIPS

What version of .NET are you building this in ?

check out these links:

This error is usually caused by some process that doesn't have enough permissions to run. I had this issue before and it solved my problem.

I basically used the new AddFullTrustModuleInSandboxAppDomain method. (check links for more info)

Where exactly do you get this error? When trying to create the proxy ? Or when the plugin is trying to do something (create a report, .. ) ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top