When you create a new User in CRM you may end up getting below error,
 

Unexpected error
An error has occurred.

Try this action again. If the problem continues,
check with Microsoft Dynamics CRM Community for solutions or
support.

With this blog my intention is to put some light on what is happening / causing this issue. Obviously the above error is very generic and it is hard to identify
actual issue. Hence as always we need to take a PF trace to understand what is happening in the background.

To enable PF trace either you can follow the KB article, http://support.microsoft.com/kb/907490

OR

Download the CRM Diagnostic tool from https://crmdiagtool2011.codeplex.com

If you see below error in the PF trace, you can fix the issue following the solution part mentioned below

Web Service Plug-in failed in SdkMessageProcessingStepId:
{5ACABB1B-EA3E-DB11-86A7-000A3A5473E8}; EntityName: systemuser; Stage: 30;
MessageName: Create; AssemblyName:
Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel,
Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName:
Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception: Unhandled
Exception: System.Reflection.TargetInvocationException: Exception has been
thrown by the target of an invocation.

 

>System.Collections.Generic.KeyNotFoundException: Microsoft Dynamics CRM has experienced an error. Reference number for
administrators or support: #60A5CF9F: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

> at Microsoft.Crm.ObjectModel.UserSettingsServiceInternal`1.PopulateOrgDefaults(IBusinessEntity entity, ExecutionContext context)

> at Microsoft.Crm.ObjectModel.UserSettingsServiceInternal`1.Create(IBusinessEntity usersettings, ExecutionContext context)

> at Microsoft.Crm.ObjectModel.SystemUserServiceInternal`1.CreateDefaultUserSettings(Guid userId, Guid businessId, ExecutionContext context)

> at Microsoft.Crm.ObjectModel.SystemUserServiceInternal`1.CreateInternal(Guid organizationId, IBusinessEntity systemuser, ExecutionContext context)

> at Microsoft.Crm.ObjectModel.SystemUserServiceInternal`1.Create(IBusinessEntity systemuser, ExecutionContext context)

 

Cause

This issue happens because .NET Framework has changed the Format of Date and Time in the Dictionary structure on Versions 2.0, 3.0, and 4.0.

For Instance,

In .NET Framework 3.5 and lower there were the following formats available for DateFormatCode for 6153 LocaleId (English-Ireland)

0: d/M/yy

1: dd/MM/yy

2: dd/MM/yyyy

3: yyyy/MM/dd

 

In .NET Framework 4.0 and higher there are the following formats available for DateFormatCode for 6153 LocaleId (English-Ireland)

0: dd/MM/yyyy

1: yyyy/MM/dd

 For German locale (1031) in .net Framework 4, the following short Date formats are available:

0: dd/ MMM/ yyyy

1: dd/MM/yy

2: dd/MM/yyyy

3: yyyy/MM/dd

 The same is applicable for the TimeFormatCode.

On .NET framework 2, 3, and 3.5 the Localization 1046 (PT-BR) has 2 time format:

0: HH:mm

1: H:mm

However in .NET 4.0 1046 has only 1 time format:

 

0: HH:mm

So if the DateFormatCode, TimeFormatCode, DateFormatString and TimeFormatString in the CRM DB doesn’t match / not found in .NET Framework dictionary structure you
won’t be able to add new users in CRM.

This issue usually happens in upgraded CRM environments.

 

Solution

 

The solution is to change the value of Format in DB, It could be DateFormatCode OR TimeFormatCode or may be both to the one existing / matching the Dictionary.

For this we need to first identify the Format in CRM DB. Run below SQL statement against the Org_MSCRM DB to get these details.

SELECT Name,
DateFormatCode, TimeFormatCode, DateFormatString, TimeFormatString, LocaleId
FROM Org_MSCRM

In one of my case I got below results for this,

Name   

DateFormatCode    

TimeFormatCode   

DateFormatString      

TimeFormatString       
   

LocaleId

 

Org_MSCRM    
         

        
4

         
0

dd.MM.yyyy      

    
HH:mm   

 
1031

 

 

Looking at the LocaleId we can identify this is German Locale and DateFormatCode 4 is not available in the Dictionary structure (Refer to the above list for German locale). To match to the .NET Framework dictionary structure I had to update the
DateFormatCode as ‘2’.

I have updated DB using below SQL statement, Followed by an IIS reset.

Update organization
set DateFormatCode = 2 Where name = ‘Org_MSCRM’