名称为 account 的代理类型已由另一个程序集定义 - CRM 365 Earyl-bound 类

问题描述 投票:0回答:1

我目前正在致力于在单个控制台应用程序中连接到两个 CRM(2011 本地部署和 365 在线)。一切正常,直到我尝试同时使用两个早期绑定的类库,此时我遇到了标题错误

这是我的代码:

using (OrganizationServiceProxy crmProxy = CrmHelper.GetServiceProxy(config.CrmUri, _syncU[1], config.SerwisUserPassword, _syncU[0]))
{
   CRM2011.Account accCRM = crmProxy.Retrieve(CRM2011.Account.EntityLogicalName, Guid.Parse("C67CF43C-D6AE-ED11-A4A2-00155D00E457"), new ColumnSet(true)).ToEntity<CRM2011.Account>();
   name = accCRM.Name;
}
string connectionString = "AuthType=Office365;Username = username;Url = https://****.api.crm4.dynamics.com;Password = password;";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
CrmServiceClient conn = new CrmServiceClient(connectionString);
CRM365.Account acc = new CRM365.Account();
acc.Name = name;
conn.Create(acc);

当我调用 Create 方法时,我收到此错误。

如果我这样调用它,一切都会正确进行,但不方便并且容易出错。

Entity acc = new Entity("account");
acc.Attributes.Add("name", name);
conn.Create(acc);

我已经尝试了网上找到的所有方法,包括这个,但没有成功:

proxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior(Assembly.GetExecutingAssembly()));

如有任何帮助,我将不胜感激。

c# dynamics-crm dynamics-crm-2011 early-binding
1个回答
0
投票

这是我从使用 CRM 代理解析器的第一天起就遇到的问题。它将尝试自动查找您正在检索/创建的实体的类类型。解决方法是从早期绑定的程序集中删除

[assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]
属性。

© www.soinside.com 2019 - 2024. All rights reserved.