CRM Development Troubleshooting Quick Tip

There may be times when developing custom Dynamics CRM components that errors occur which may or may not involve your code.

This, of course, has never happened to me because I write bug-free code all of the time-but I have seen it happen to other developers. Smile

Any, you may find yourself staring at an error message that looks something like this:

Unhandled Exception: System.ServiceModel.FaultException`1
[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, 
Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: 
An unexpected error occurred.Detail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147220891</ErrorCode>
  <ErrorDetails 
    xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
    <KeyValuePairOfstringanyType>
      <d2p1:key>OperationStatus</d2p1:key>
      <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" 
                  i:type="d4p1:int">0</d2p1:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <Message>An unexpected error occurred.</Message>
  <Timestamp>2012-11-19T15:55:39.8208026Z</Timestamp>
  <InnerFault>
    <ErrorCode>-2147220891</ErrorCode>
    <ErrorDetails 
       xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
      <KeyValuePairOfstringanyType>
        <d3p1:key>OperationStatus</d3p1:key>
        <d3p1:value xmlns:d5p1="http://www.w3.org/2001/XMLSchema" 
                    i:type="d5p1:int">0</d3p1:value>
      </KeyValuePairOfstringanyType>
    </ErrorDetails>
    <Message>An unexpected error occurred.</Message>
    <Timestamp>2012-11-19T15:55:39.8208026Z</Timestamp>
    <InnerFault>
      <ErrorCode>-2147220891</ErrorCode>
      <ErrorDetails 
          xmlns:d4p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <d4p1:key>OperationStatus</d4p1:key>
          <d4p1:value xmlns:d6p1="http://www.w3.org/2001/XMLSchema" 
                      i:type="d6p1:int">0</d4p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>An unexpected error occurred.</Message>
      <Timestamp>2012-11-19T15:55:39.8208026Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText i:nil="true" />
    </InnerFault>
    <TraceText i:nil="true" />
  </InnerFault>
  <TraceText>

So what does all of this mean?  Well, as it states, An unexpected error occurred. But what exactly was so unexpected? 

The actual cause can sometimes be hard to track down, but here’s a tip:

1. Open the Windows calculator.

2. Set the View to Programmer.

image

3. With the mode set to Dec, for Decimal, past in the ErrorCode found on this line:

<ErrorCode>-2147220891</ErrorCode>

4. Change the mode to Hex. This will convert the number from Decimal to Hexadecimal.

image

5. Select Edit, Copy to copy this value to the clipboard.

6. Open the CRM 2011 SDK help file.

7. Paste the value you copied in Step 5 into the Search box.

8. Remove FFFFFFFF from the value.

9. Click the List Topics button.

10. If that error exists within the SDK, it will probably be found in the topic: Web Service Error Codes.

11. Click once anywhere within the topic window.

12. Press Ctrl+F, for Find.

13. Past the value from the Topic Search box into the Find box.

14. You should be taken to the error code:

image

 

Not all error codes are documented but most are and this technique can really save you time when troubleshooting your code.

Leave a Reply 1 comment