When validating a Data Source (DB) from the form Data Import Export Framework > Setup > Source Data Formats, the following exception was thrown:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.
After examining the underlying code, it pointed to the a specific table.
NB! I have deliberately choosen not to reveal the real table or column name (pretty obvious)
- Run a simple SELECT from the table.
- Check if a value is stored in the "Secret" Column for the Data Source Type (typically DB:Database).
- If you find a value in this "Secret" Column, try to run a simple UPDATE statement to clear the value.
- Do a Log Off - Log On Sequence in the AX Windows Client and try to validate the Data Source again and you will probably have solved your issue.
When replacing the Business Database, it's always a Best Practice to create a new GLOBALGUID. It could be that the GLOBALGUID is used as the or part of the Encryption Key. After changing the GLOBALGUID, it's no longer possible to Decrypt the information stored in the table (and that's the way it should be).