System.Security.Cryptography.CryptographicException when removing Enterprise Library

Topics: Cryptography Application Block, Data Access Application Block
Jul 29, 2009 at 4:35 PM


I was trying to use Enterprise Library to encrypt my connection string stored in App.config file. In the beginning everything works fine. What I did was

1. Open Enterprise Library Configuration

2. Locate App.config file.

3. Select Data Access Application Block

4. Select Protection to be DataProtectedConfigurationProvider

Then I noticed that the connection string is now being encrypted, and I can still run the program.

However, after a while when I want to remove the encryption, I simple replace the encrypted app.config back with unencrypted app.config. When I run my program again, I get the following error:

A first chance exception of type 'System.Security.Cryptography.CryptographicException' occurred in mscorlib.dll
A first chance exception of type 'System.TypeInitializationException' occurred in XXXX.exe

After that, I tried to replace it back with Encrypted App.config, Change Protection Provider, and anything I can think of, I still get this error. I believe the inner error for the exception is "Bad Data".


Can anyone help me with this?


Best Regards,


Jul 30, 2009 at 11:29 AM
Edited Jul 30, 2009 at 11:56 AM


I cant reproduce your error. I tried it the way you've described, It seems that I'm getting your error. maybe I'm missing something , can you give more hint how can I reproduce this.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Jul 31, 2009 at 4:13 PM

Hi Valiant,


Thank you very much for your help. I finally solved it by adding the proctection provider back and restart my machine. Not sure why I have to restart it, but it's now solved.


Best Regards,