开发者

Why did SQL Server Management Studio 2008 command-line switches stop working?

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.12开发者_运维问答3.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.


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;
}


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


Works fine like this:

sqlwb.exe -S . -E -d dbName


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜