SQL Server 2008 R2 - .NET Framework 未处理的异常
我在一台新电脑上安装了 SQL Server 2008 R2。一切都工作正常,直到我开始从旧 PC 上的 SQL Server 2008 R2 管理工作室导出注册服务器。当我将其中一台注册服务器导入新安装时,出现错误“密钥在指定状态下使用无效”。
现在,每次我尝试在新安装上打开注册服务器时,我都会收到带有相同消息的 .NET Framework 未处理异常。注册的服务器区域完全是空的。现在无法添加任何已注册的服务器。我已经尝试重新安装 SQL,但错误仍然存在。这显然与进口流程有关。也许有什么东西被损坏了。有谁知道如何修复它?
编辑:异常对话框中的详细信息
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
听起来像是您的 Windows 配置文件中的某些内容(例如 Windows 7 上的 Users/[Username]/AppData/Roaming)。您是否尝试过从中清除 SQL Server 条目?
艾伦
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
RegSrvr.xml 文件对我来说也是问题。但我并没有删除整个文件,而是对其进行了编辑以删除加密的密码字符串。之后,Management Studio 可以正常打开,并且所有导入的服务器都存在。
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.
我也有过非常类似的情况。完全相同的观察结果 - 但它与进口无关。我已经完全重新安装了 Windows 7 和 SQL(开发人员版)。我已经恢复了重建之前的配置文件,因此它与安装不同步。我删除了C:\Users\John\AppData\Roaming\Microsoft\Microsoft SQL Server,问题就消失了。
I had avery similar situation. Exact same observations - but it had nothing to do with importing. I had done a complete reinstall of Windows 7, and SQL (Developer edition). I had recovered my profile from before the rebuild so it was out of sync with the install. I deleted C:\Users\John\AppData\Roaming\Microsoft\Microsoft SQL Server and the problem went away.
还有一件事需要检查 - 您无法将导出的定义导入到早期版本的 SQL Management Studio 中。您将收到相同的
Key not valid for use
错误,例如,从 MSSMS2012 导出并尝试在 MSSMS2008R2 中导入。One more thing to check - you can't import exported definitions into earlier versions of SQL Management Studio. You'll get the same
Key not valid for use
error, for example, exporting from MSSMS2012 and trying to import in MSSMS2008R2.还有一件事需要检查 - 对我来说这是因为 SQL Server 驱动器中没有足够的磁盘空间。清理空间解决了一切。
One more thing to check - for me it was because there was no enough disk space in the drive of SQL Server. Clearing space resolved everything.