CRM 2011 Error: "Key not valid for use in specified state." (System.Security.Cryptography.CryptographicException)

This happens very rarely. When connecting your application to CRM 2011 Online version, you get following error which fails at the DeviceIdManager.LoadOrRegisterDevice() method with the following exception:

“Key not valid for use in specified state.” (System.Security.Cryptography.CryptographicException)
   at System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope)
    at Microsoft.Crm.Services.Utility.DeviceUserName.Decrypt(String value) in z:PracticeCrmXpress.WinForms.TestDeviceIdManager.cs:line 876
    at Microsoft.Crm.Services.Utility.DeviceUserName.UpdateCredentials(String encryptedValue, String decryptedValue) in z:PracticeCrmXpress.WinForms.TestDeviceIdManager.cs:line 849
    at Microsoft.Crm.Services.Utility.DeviceUserName.set_EncryptedPassword(String value) in z:PracticeCrmXpress.WinForms.TestDeviceIdManager.cs:line 142
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLiveDevice.Read2_DeviceUserName(Boolean isNullable, Boolean checkType)
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLiveDevice.Read3_LiveDevice(Boolean isNullable, Boolean checkType)
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLiveDevice.Read4_Data()

You have done nothing wrong!! Here are the steps to resolve it:

1. Go to path: C:\Users<current user>\LiveDeviceID\
2. Delete the LiveDevice.xml
3. Try to connect from the application.
4. If this doesn’t solve the error, follow steps 1 and 2, reboot and try connecting from the application.

See related article: CRM 2011 Error: There is an error in XML document (5, 5)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s