Dynamic CRM 2013学习笔记(三十)Linq使用报错 A proxy type with the name account has been defined by another assembly
2015-01-27 17:11
701 查看
在CRM中使用linq时,有时会报这个错误:
A proxy type with the name account has been defined by another assembly.
Current type: Account, MyAssembly, Version=1.0.0.4, Culture=neutral, PublicKeyToken=be9afbacb707a086,
Existing type: Account, CustomPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Parameter name: account”
网上一搜索,有人说解决很简单:
[/code]
再到项目里一看,发现就没有这个CrmConnection:
原来是用的OrganizationServiceProxy,于是把它改成OrganizationService,因为OrganizationService里面会用到这个CrmConnection:
改完后,就不报这个错了。
Dynamic CRM 2013学习笔记 系列汇总 -- 持续更新中
A proxy type with the name account has been defined by another assembly.
Current type: Account, MyAssembly, Version=1.0.0.4, Culture=neutral, PublicKeyToken=be9afbacb707a086,
Existing type: Account, CustomPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Parameter name: account”
网上一搜索,有人说解决很简单:
[code]var connection = CrmConnection.Parse(connectionString);
connection.ProxyTypesAssembly = Assembly.GetExecutingAssembly();
[/code]
再到项目里一看,发现就没有这个CrmConnection:
Uri orgServiceUri = new Uri(CRMServiceUrl + "/XRMServices/2011/Organization.svc");
ClientCredentials credentials = new ClientCredentials();
if (CRMAuthenticationType == "AD")
{
credentials.Windows.ClientCredential = new System.Net.NetworkCredential(CRMUserName, CRMUserPassword, CRMUserDomainName);
}
else if (CRMAuthenticationType == "ADFS")
{
credentials.UserName.UserName = CRMUserDomainName + "\\" + CRMUserName;
credentials.UserName.Password = CRMUserPassword;
}
OrganizationServiceProxy crmServiceProxy = new OrganizationServiceProxy(orgServiceUri, null, credentials, null);
crmService = (IOrganizationService)crmServiceProxy;
原来是用的OrganizationServiceProxy,于是把它改成OrganizationService,因为OrganizationService里面会用到这个CrmConnection:
ClientCredentials credentials = new ClientCredentials();
if (CRMAuthenticationType == "AD")
{
credentials.Windows.ClientCredential = new System.Net.NetworkCredential(CRMUserName, CRMUserPassword, CRMUserDomainName);
}
else if (CRMAuthenticationType == "ADFS")
{
credentials.UserName.UserName = CRMUserDomainName + "\\" + CRMUserName;
credentials.UserName.Password = CRMUserPassword;
}
string server = string.Format("Url={0};Domain={1};Username={2};Password={2}", CRMServiceUrl, CRMUserDomainName, CRMUserName, CRMUserPassword);
var connection = CrmConnection.Parse(server);
connection.ProxyTypesAssembly = Assembly.GetExecutingAssembly();
connection.ClientCredentials = credentials;
m_CrmService = new OrganizationService(connection);
m_SvcContext = new ServiceContext(m_CrmService);
改完后,就不报这个错了。
Dynamic CRM 2013学习笔记 系列汇总 -- 持续更新中
相关文章推荐
- Unity错误——1.error CS1704: An assembly with the same name `UnityEngine.UI' has already been imported.
- struts中使用json,报错There is no result type defined for type 'json' mapped with name 'success'.
- EntityType [TableName] has no key defined. Define the key for this EntityType
- Warning[Pe301]: typedef name has already been declared (with same type)问题解决方法
- .net4 wpf App 使用log4net 错误:The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)
- Dynamic CRM 2013学习笔记(十八)根据主表状态用JS控制子表自定义按钮
- Linq To xRM Issue(CRM 4.0 Online): The 'select' and 'orderBy' calls may only reference a single common entity type.
- Dynamic CRM 2013学习笔记(三十九)流程2 - 业务流程(Business Process Flows)用法详解
- WMI005-WMI学习笔记(五)——Using WMI with the .NET Framework(.NET框架使用WMI)
- Visual studio 2013打开报异常"Exception has been thrown by the target of an invocation"
- Dynamic CRM 2013学习笔记(十六)用JS控制Tab可见,可用
- Attribute name "aphmodel" associated with an element type "mxg" must be followed by the ' = ' charac
- Dynamic CRM 2013学习笔记(十七)JS读写各种类型字段方法及技巧
- CRM SaveChanges Exception has been thrown by the target of an invocation
- RocketMQ:The producer group has been created before, specify another name please.
- Caused by: There is no result type defined for type 'json' mapped with name 'success'. Did you mean
- 学习笔记:出现错误ActivityManager: Warning: Activity not started, its current task has been brought to the fr
- Dynamic CRM 2013学习笔记(四十三)流程6 - 自定义流程活动
- Dynamic CRM 2013学习笔记(三十七)自定义审批流7 - 初始化(整套审批流下载、安装)
- Dynamic CRM 2013学习笔记(十六)用JS控制Tab可见,可用