1

Closed

Simple account update gives error: 0x80040216

description

From the demo/sample i loop throug All my contacts, that works great; but when an update is requested / a soap error occurs; as you can see in the trace:
 
Can you tell me where i go wrong ?
 
Bob.
 
Here the code -
 
  foreach (var person in people)
            {
                Console.WriteLine("{0} {1}", person.FirstName, person.LastName);
 
                person.FirstName += ".";
---> Here it goes wrong crmService.Update(person);
            }
 
A simple class towards Contacts:
 
[XrmEntity("contact")]
public class Person : IXrmEntity
{
    [XrmFieldMapping("contactid", CrmType = AttributeType.Lookup)]
    public Guid Id { get; set; }
 
    [XrmFieldMapping("firstname")]
    public string FirstName { get; set; }
 
    [XrmFieldMapping("lastname")]
    public string LastName { get; set; }
 
    //[XrmFieldMapping("description", CrmType = AttributeType.Memo)]
    //public string Description { get; set; }
 
    [XrmReferenceType("account")]
    [XrmFieldMapping("parentcustomerid", CrmType = AttributeType.Customer)]
    public XrmReference Account { get; set; }
 
    [XrmFieldMapping("createdon", CrmType = AttributeType.DateTime)]
    public DateTime CreatedOn { get; set; }
 
    [XrmFieldMapping("statecode", CrmType = AttributeType.State)]
    public string State { get; set; }
 
    [XrmFieldMapping("statuscode", CrmType = AttributeType.Status)]
    public XrmStatusInfo Status { get; set; }
 
    [XrmFieldMapping("ownerid", CrmType = AttributeType.Owner)]
    public XrmReference User { get; set; }
 
    public Person()
    { }
}
 
I show the debugging info so you see what is loaded:
 
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Users\datasc\Documents\Visual Studio 2008\Projects\CRMDemo\CRMDemo\bin\Debug\CRMDemo.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_32\microsoft.crm.sdk\4.0.0.0__31bf3856ad364e35\microsoft.crm.sdk.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_32\microsoft.crm.sdktypeproxy\4.0.0.0__31bf3856ad364e35\microsoft.crm.sdktypeproxy.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_32\microsoft.crm.sdktypeproxy.xmlserializers\4.0.0.0__31bf3856ad364e35\microsoft.crm.sdktypeproxy.xmlserializers.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0xd7c has exited with code 0 (0x0).
The thread 0x81c has exited with code 0 (0x0).
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Users\datasc\Documents\Visual Studio 2008\Projects\CRMDemo\CRMDemo\bin\Debug\CRMDemo.exe', Symbols loaded.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Users\datasc\Documents\Visual Studio 2008\Projects\CRMDemo\CRMDemo\bin\Debug\Streamline.Xrm.DevelopmentToolkit.dll', Symbols loaded.
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x1088 has exited with code 0 (0x0).
My name
'CRMDemo.vshost.exe' (Managed): Loaded 'C:\Users\datasc\Documents\Visual Studio 2008\Projects\CRMDemo\CRMDemo\bin\Debug\Streamline.Helpers.dll'
Server was unable to process request..
0x80040216
An unexpected error occurred.
Platform
 
A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll
The thread 0xeb8 has exited with code 0 (0x0).
The thread '<No Name>' (0x11d4) has exited with code 0 (0x0).
The program '[5664] CRMDemo.vshost.exe: Managed' has exited with code 0 (0x0).
Closed Jan 21, 2010 at 5:08 PM by kgooding

comments

bvschie wrote Jan 20, 2010 at 8:43 PM

Solved:

changed:
    [XrmFieldMapping("contactid", CrmType = AttributeType.Lookup)]
    public Guid Id { get; set; }
into:
[XrmFieldMapping("contactid", CrmType = AttributeType.PrimaryKey)]
    public Guid Id { get; set; }

kgooding wrote Jan 21, 2010 at 5:08 PM

Glad you solved this without my help =)

You can actually leave out the field mapping entirely for the Id property, reflection will be used to set it accordingly.

Let me know if you have any questions/comments, I love to hear feedback!

Thanks, Kurt.

wrote Jan 21, 2010 at 5:08 PM

wrote Feb 13, 2013 at 12:37 AM

wrote May 15, 2013 at 12:11 AM