【问题标题】:early bound entity classes dynamics CRM 2011, Error while updating or deleting早期绑定实体类动态 CRM 2011,更新或删除时出错
【发布时间】:2015-08-06 03:50:51
【问题描述】:

我现在使用 CrmScUtil 创建 CrmProxy 类,当我尝试使用它时遇到了一些问题。

创建联系人可以正常工作,但更新和删除只会引发此错误:

{“处理此请求时发生错误。”}

在 Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges(SaveChangesOptions 选项) 在 Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges()

能否请您告诉我我做错了什么?查询有效,它返回我尝试更新/删除的联系人数据。

OrganizationServiceProxy orgserv; orgserv = new OrganizationServiceProxy(orgConfigInfo, clientCreds); orgserv.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

        //Create            
        using (var context = new XrmContext(orgserv))
        {
            Contact contact = new Contact()
            {
                FirstName = "fName",
                LastName = "lName",
                Address1_Line1 = "Address1_Line1",
                Address1_City = "Address1_City",
                Address1_StateOrProvince = "XX",
                Address1_PostalCode = "00000",
                Telephone1 = "(000) 000-0000",
                JobTitle = "JobTitle",
                Company = "Company",
                EMailAddress1 = "test@test.com"
            };
            context.AddObject(contact);
            context.SaveChanges();
        }
        //End Create

        //Update
        using (var contextUpdate = new XrmContext(orgserv))
        {
            try
            {
                Contact con = contextUpdate.ContactSet.FirstOrDefault(c => c.EMailAddress1 == "test@test.com");
                if (con != null)
                {
                    con.Fax = "Fax132456";
                    contextUpdate.UpdateObject(con);
                    contextUpdate.SaveChanges();
                }
            }
            catch (Exception ex)
            {

            }
        }
        //End Update


        //Delete
        using (var contextDelete = new XrmContext(orgserv))
        {
            Contact con = contextDelete.ContactSet.FirstOrDefault(c => c.EMailAddress1 == "test@test.com");
            if (con != null)
            {
                contextDelete.DeleteObject(con);
                contextDelete.SaveChanges();
            }
        }
        //End Delete

【问题讨论】:

    标签: dynamics-crm-2011


    【解决方案1】:

    我已经找到了答案,我希望这会有所帮助:

    最新的 CoreAssamblies (7.1.0) 似乎存在错误

    所以关键是卸载NuGet包并安装7.0.0

    安装包 Microsoft.CrmSdk.CoreAssemblies -Version 7.0.0

    之后就没有问题了。

    【讨论】:

      猜你喜欢
      • 2013-02-05
      • 1970-01-01
      • 1970-01-01
      • 2012-07-12
      • 1970-01-01
      • 2016-01-06
      • 2018-09-22
      • 2015-09-18
      • 1970-01-01
      相关资源
      最近更新 更多