Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 R2 - .NET Framework unhandled exception

I have installed SQL Server 2008 R2 on a new PC. Everything was working fine until I started exporting registered servers from the SQL Server 2008 R2 management studio which exist on my old PC. When I imported one of the registered servers to my new installation I got and error "Key not valid for use in specified state".

Now everytime I try to open registered servers on the new installation I get a .NET framework Unhandled Exception with the same message. The registered server area is completely empty. There is no way of adding any registered servers now. I have tried reinstalling SQL but the error remains. It is obviously related to the import process. Maybe something got corrupted. Does anyone know how to fix it?

Edit:Details from exception dialog

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.

   at System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope)
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServer.ProtectData(String input, Boolean encrypt)
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServer.get_SecureConnectionString()
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServer.get_ConnectionString()
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServer.get_ServerName()
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServerTree.AddRegisteredServerNode(RegisteredServer regSrv, TreeNodeCollection nodes)
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServerTree.AddServerGroupToNodeCollection(ServerGroup group, TreeNodeCollection nodes, Boolean createRecursively)
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServerTree.AddServerGroupToNodeCollection(ServerGroup group, TreeNodeCollection nodes, Boolean createRecursively)
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServerTree.Initialize(ServerGroup localServerGroup, ServerType serverType, IServerType connDlgServerType, AddCentralManagementServerDelegate onAddCentralManagementServer, AddNewCentralManagementServerDelegate onAddNewCentralManagementServer, DeleteCentralManagementServerDelegate onDeleteCentralManagementServer, GetServiceProviderDelegate onGetService)
   at Microsoft.SqlServer.Management.RegisteredServers.RegisteredServerControl.RegisteredServerControl_Load(Object sender, EventArgs e)
   at System.Windows.Forms.UserControl.OnLoad(EventArgs e)
   at System.Windows.Forms.UserControl.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.UserControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
like image 928
user718982 Avatar asked Apr 21 '11 13:04

user718982


2 Answers

Sounds like it is something in your windows profile (e.g. Users/[Username]/AppData/Roaming on Windows 7). Have you tried clearing the SQL Server entries from that?

Alan

like image 126
Alan Spark Avatar answered Oct 11 '22 05:10

Alan Spark


The RegSrvr.xml file was the problem for me too. But rather than delete the whole file, I just edited it to delete out the encrypted password strings. After that, Management Studio opened fine with all the imported servers present.

like image 25
kukabuka Avatar answered Oct 11 '22 06:10

kukabuka