【问题标题】:Creating OrganizationServiceProxy in CRM2011 Plugin在 CRM2011 插件中创建 OrganizationServiceProxy
【发布时间】:2013-08-15 12:05:19
【问题描述】:

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

在插件执行中,我想创建一个 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' 失败。

搜索了相同的问题,但没有工作,请提出建议。

【问题讨论】:

  • 在这里长镜头:沙盒插件限制了对本地主机的访问(环回)。您是否在与您尝试连接的服务器相同的服务器上运行您的 CRM 组织?
  • 我在 Online CRM 上使用我的插件并尝试连接另一个 Online CRM。有什么想法吗?

标签: dynamics-crm-2011 dynamics-crm dynamics-crm-online


【解决方案1】:

您在哪个版本的 .NET 中构建它?

查看以下链接:

此错误通常是由某些没有足够权限运行的进程引起的。我之前遇到过这个问题,它解决了我的问题。

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

您究竟是从哪里得到这个错误的?尝试创建代理时?或者当插件试图做某事时(创建报告,..)?

【讨论】:

  • 内部插件 ClientCredentials creds = new ClientCredentials(); creds.UserName.UserName = ""; creds.UserName.Password = ""; OrganizationServiceProxy 服务 = new OrganizationServiceProxy(newUri("https://...Organization.svc"), null, creds,null);可以在 Online CRM 中创建 OrganizationServiceProxy 对象。或者有没有其他方法,请指教。
【解决方案2】:

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

找到了使用它的最佳方式。

创建 Azure Web 服务并在 Plugin 中使用该服务,它可以工作。

【讨论】:

    猜你喜欢
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 2011-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-19
    • 2018-03-09
    相关资源
    最近更新 更多