为什么 SQL Server Management Studio 2008 命令行开关停止工作?

发布于 2024-09-10 13:04:40 字数 1027 浏览 5 评论 0 原文

我一直严重依赖 Windows 的 SSMS 快捷方式,其中包括命令行开关,使我能够快速打开特定服务器上的特定数据库。例如

Ssms.exe -S 123.123.123.123 -U sa -P goodpassword -d DbName

Ssms.exe -S . -E -d DbName

这些突然停止工作。我从 SSMS 收到此错误:

Failed to create new SQL Server script.
Object reference not set to an instance of an object. (AppIDPackage)
Program Location: at Microsoft.SqlServer.Management.UI.VSIntegration.
AppIDPackage.AppIDPackage.OpenConnectionDialogWithGlobalConnectionInfo()

我仍然可以在没有命令行开关的情况下启动 SSMS,然后手动建立连接。一些命令行开关仍然有效,例如

ssms.exe -nosplash

工作正常。

使用 -S、-E 和 -d 命令行开关的任意组合都会出现相同的错误。我是否指向有效的服务器或数据库,或者我的登录凭据是否良好并不重要。我可以指出 SSMS 的旧版本,它工作正常,但 2008 版本则不行。

这篇文章MSDN 论坛上的内容是我在网上找到的所有内容,但 MS 在该主题上并没有提供太多帮助。

我有什么想法可以开始解决这个问题吗?我在不同服务器上使用许多不同的数据库,并且我非常依赖这些快捷方式。

I've always relied heavily on Windows shortcuts to SSMS that include command-line switches allowing me to quickly open up a specific database on a specific server. For example

Ssms.exe -S 123.123.123.123 -U sa -P goodpassword -d DbName

or

Ssms.exe -S . -E -d DbName

These suddenly stopped working. I get this error from SSMS:

Failed to create new SQL Server script.
Object reference not set to an instance of an object. (AppIDPackage)
Program Location: at Microsoft.SqlServer.Management.UI.VSIntegration.
AppIDPackage.AppIDPackage.OpenConnectionDialogWithGlobalConnectionInfo()

I can still launch SSMS without the command-line switches, and then manually establish the connections. Some command-line switches still work, for example

ssms.exe -nosplash

works fine.

I get the same error with any combination of the -S, -E, and -d command-line switches. It doesn't matter if I'm pointing to a valid server or database or not, or if my login credentials are good or not. I can point to the older version of SSMS and it works fine, but not the 2008 version.

This post on MSDN's forums is all I've found online, but MS hasn't been very helpful on this thread.

Any ideas how I might start to fix this? I work with a lot of different databases on different servers, and I really rely on these shortcuts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

冬天的雪花 2024-09-17 13:04:41

我已经将有问题的 DLL 扔到了 Reflector 上,它在这篇文章的底部给了我代码,遗憾的是,代码中没有任何明显的内容可以让您轻松弄清楚为什么它不再为您工作(不是吗?)如果 Microsoft 随其生成的针对 CLR 编写的任何内容一起提供调试符号,那该多好啊?)。

有几个地方的代码让我想知道您是否可能有损坏的“最近使用的服务器”列表或类似的内容,也许您可​​以尝试按照 这个问题来清除它们,看看是否有帮助。

private void OpenConnectionDialogWithGlobalConnectionInfo()
{
    if ((ServiceCache.GlobalConnectionInfo != null) && (ServiceCache.GlobalConnectionInfo.Count != 0))
    {
        try
        {
            using (ConnectionDialog dialog = new ShellConnectionDialog())
            {
                IDbConnection connection;
                dialog.ImportRegisteredServersOnFirstLaunch = true;
                dialog.AddServer(new SqlServerType());
                UIConnectionInfo connectInfo = ServiceCache.GlobalConnectionInfo[0].Copy();
                if (dialog.TryToConnect(this.PopupOwner, ref connectInfo, out connection) == DialogResult.OK)
                {
                    this.ScriptFactory.CreateNewBlankScript(ScriptType.Sql, connectInfo, connection);
                }
            }
        }
        catch (Exception exception)
        {
            ExceptionMessageBox box = new ExceptionMessageBox(new ApplicationException(SRError.FailedToCreateNewSqlScript, exception));
            box.Caption = SRError.MessageBoxCaption;
            box.Show(this.PopupOwner);
        }
    }
    ServiceCache.GlobalConnectionInfo = null;
}

I've thrown the DLL in question at reflector and it's given me back the code at the bottom of this post, sadly there's nothing immediately obvious in the code that makes it easy to work out why it's stopped working for you (wouldn't it be nice if Microsoft shipped debug symbols with anything they produce that's written against the CLR?).

There are a couple of places where the code makes me wonder if you might have a corrupted "recently used servers" list or something similar, perhaps you could try following the steps listed in this question to clear them out and see if that helps.

private void OpenConnectionDialogWithGlobalConnectionInfo()
{
    if ((ServiceCache.GlobalConnectionInfo != null) && (ServiceCache.GlobalConnectionInfo.Count != 0))
    {
        try
        {
            using (ConnectionDialog dialog = new ShellConnectionDialog())
            {
                IDbConnection connection;
                dialog.ImportRegisteredServersOnFirstLaunch = true;
                dialog.AddServer(new SqlServerType());
                UIConnectionInfo connectInfo = ServiceCache.GlobalConnectionInfo[0].Copy();
                if (dialog.TryToConnect(this.PopupOwner, ref connectInfo, out connection) == DialogResult.OK)
                {
                    this.ScriptFactory.CreateNewBlankScript(ScriptType.Sql, connectInfo, connection);
                }
            }
        }
        catch (Exception exception)
        {
            ExceptionMessageBox box = new ExceptionMessageBox(new ApplicationException(SRError.FailedToCreateNewSqlScript, exception));
            box.Caption = SRError.MessageBoxCaption;
            box.Show(this.PopupOwner);
        }
    }
    ServiceCache.GlobalConnectionInfo = null;
}
梓梦 2024-09-17 13:04:41

必须打开 ObjectExplorer 窗口。不要隐藏。
我这样解决了我的问题:)

The ObjectExplorer window must be open. Don't hide.
I solved my problem this way :)

输什么也不输骨气 2024-09-17 13:04:41

像这样工作正常:

sqlwb.exe -S . -E -d dbName

Works fine like this:

sqlwb.exe -S . -E -d dbName
只有影子陪我不离不弃 2024-09-17 13:04:41

我正在对 SQL2005 数据库使用 SSMS2008,并且 ssms 命令行在这里工作正常。

这是 SSMS“关于”对话框生成的版本信息:

Microsoft SQL Server Management Studio              10.0.1600.22 ((SQL_PreRelease).080709-1414 )
Microsoft Data Access Components (MDAC)             6.0.6001.18000 (longhorn_rtm.080118-1840)
Microsoft MSXML                                     2.6 3.0 5.0 6.0 
Microsoft Internet Explorer                         8.0.6001.18813
Microsoft .NET Framework                            2.0.50727.3074
Operating System                                    6.0.6001

有多个来源 (MSSqlTips此处)声明命令行参数在 sqlwb.exe 上可用。然而 ssms< 的联机丛书页面/a> 表明这些选项在 ssms 上可用。

I'm using SSMS2008 against a SQL2005 database, and the ssms command line works fine here.

This is the version info produced by the SSMS About dialog:

Microsoft SQL Server Management Studio              10.0.1600.22 ((SQL_PreRelease).080709-1414 )
Microsoft Data Access Components (MDAC)             6.0.6001.18000 (longhorn_rtm.080118-1840)
Microsoft MSXML                                     2.6 3.0 5.0 6.0 
Microsoft Internet Explorer                         8.0.6001.18813
Microsoft .NET Framework                            2.0.50727.3074
Operating System                                    6.0.6001

There are several sources (MSSqlTips, and here) that state the command line arguments are available on sqlwb.exe. Yet the Books Online page for ssms states that the options are available on ssms.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文