Dynamics crm 2011 在CRM2011插件中创建OrganizationServiceProxy

Dynamics crm 2011 在CRM2011插件中创建OrganizationServiceProxy,dynamics-crm-2011,dynamics-crm,dynamics-crm-online,Dynamics Crm 2011,Dynamics Crm,Dynamics Crm Online,我已经创建了一个插件并成功注册(沙盒隔离模式) 在插件执行内部,我想创建OrganizationServiceProxy的一个对象,它使用另一个CRM详细信息。使用以下代码: Uri oUri = new Uri("https://yourorg.api.crm5.dynamics.com/XRMServices/2011/Organization.svc"); //** Your client credentials ClientCredent

我已经创建了一个插件并成功注册(沙盒隔离模式)

在插件执行内部,我想创建OrganizationServiceProxy的一个对象,它使用另一个CRM详细信息。使用以下代码:

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);
我遇到安全异常:

System.Security.SecurityException:请求“System.Security.Permissions.SecurityPermission,mscorlib, 版本=4.0.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089'失败


已搜索同一问题,但不起作用,请提出建议。

您正在使用哪个版本的.NET构建此问题

查看以下链接:

此错误通常是由于某些进程没有足够的权限运行而导致的。我以前有过这个问题,它解决了我的问题

我基本上使用了新的
AddFullTrustModuleInSandboxAppDomain
方法。(有关更多信息,请查看链接)


你到底从哪里得到这个错误的?当尝试创建代理时?或者当插件尝试执行某些操作时(创建报告,…)

我搜索了很多,但是插件是在沙盒模式下注册的,因此它不允许访问外部服务

找到了最好的使用方法


创建了Azure web服务并在插件中使用该服务,它可以正常工作。

这里有一个长远之计:沙盒插件限制了对本地主机的访问(环回)。您是否在与您尝试连接的服务器相同的服务器上运行CRM组织?我正在在线CRM上使用我的插件,并尝试连接另一个在线CRM。有什么想法吗?内置插件ClientCredentials creds=newclientcredentials();creds.UserName.UserName=“”;creds.UserName.Password=“”;OrganizationServiceProxy服务=新的OrganizationServiceProxy(newUri(“https://...Organization.svc)、无效、信誉、无效);可以在联机CRM中创建OrganizationServiceProxy对象。或者有没有其他办法,请建议。