Creación de OrganizationServiceProxy en el complemento CRM2011

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("");
            //** Your client credentials 
            ClientCredentials clientCredentials = new ClientCredentials();
            clientCredentials.UserName.UserName = "";
            clientCredentials.UserName.Password = "YourAdminPassword";

            //Create your Organization Service Proxy
            OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(

I am getting Security Exception:

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

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

preguntado el 15 de agosto de 13 a las 13:08

Taking a long shot here: sandbox plugins have restricted access to localhost (loopback). Are you running you CRM org on same server as the one you are trying to connect? -

I am using my plugin on Online CRM and try to connect another Online CRM. Any idea? -

2 Respuestas

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, .. ) ?

Respondido 15 ago 13, 13:08

Inside Plugin ClientCredentials creds = new ClientCredentials(); creds.UserName.UserName = "<username>"; creds.UserName.Password = "<password>"; OrganizationServiceProxy service = new OrganizationServiceProxy(newUri("https://...Organization.svc"), null, creds,null); Is is possible to create OrganizationServiceProxy object in Online CRM. or is there any other way, please suggest. - anil p

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.

Respondido 30 ago 13, 12:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.