Options

Unhandled exception... "Unable to cast..."

joltcoderoldjoltcoderold Posts: 4 Bronze 2
edited February 28, 2007 6:46AM in SQL Prompt Previous Versions
"Unable to cast object of type 'System.DBNull' to type 'System.String'."

I can repro this on every database that I initially connect to or "refresh" the cache manually. The exception prevents *any* items to be added to the intellisense; whether I click continue or close the window. I am running this on Windows Vista against a Sql2005 database. I haven't yet tried to repro using XP as machines running xp are harder for me to come by these days. I've used integrated and sql authentication; in neither case is my account an admin SQL database.

Any help would be appreciated...


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

************** Exception Text **************
System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.
at _34._22(SqlConnection )
at _34._1(_33 )
at RedGate.SQLCompare.Engine.Database.RegisterForSqlPrompt(ConnectionProperties connectionProperties, Options options, Boolean includeSystemObjects)
at _74.Refresh(IAuthenticationTokenProvider provider)
at RedGate.SqlPrompt.Engine.Cache.MetaDataCache.Refresh(IAuthenticationTokenProvider provider)
at _19.DoTask()
at RedGate.SQLPrompt.CommonUI.TaskExecuter.Executer._1()


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
AppIDPackage
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/AppIDPackage.DLL
Microsoft.SqlServer.SqlTools.VSIntegration
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.SqlTools.VSIntegration.DLL
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
Microsoft.VisualStudio.Shell.Interop
Assembly Version: 7.1.40304.0
Win32 Version: 7.0.4054
CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Shell.Interop/7.1.40304.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.Interop.dll
Microsoft.VisualStudio.OLE.Interop
Assembly Version: 7.1.40304.0
Win32 Version: 7.0.4054
CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.OLE.Interop/7.1.40304.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.OLE.Interop.dll
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
SqlWorkbench.Interfaces
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/SqlWorkbench.Interfaces.DLL
Microsoft.SqlServer.SqlTDiagM
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1399.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SqlTDiagM/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.SqlTDiagM.dll
Microsoft.DataWarehouse.SQM
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/Microsoft.DataWarehouse.SQM.DLL
Microsoft.SqlServer.Instapi
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1399.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Instapi/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.Instapi.dll
RedGate.SQLPrompt.SSMSUI
Assembly Version: 3.0.0.868
Win32 Version: 3.0.0.868
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.SQLPrompt.SSMSUI.dll
Extensibility
Assembly Version: 7.0.3300.0
Win32 Version: 7.00.9466
CodeBase: file:///C:/Windows/assembly/GAC/Extensibility/7.0.3300.0__b03f5f7f11d50a3a/Extensibility.dll
EnvDTE
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.867 (vsvista.050727-8600)
CodeBase: file:///C:/Windows/assembly/GAC/EnvDTE/8.0.0.0__b03f5f7f11d50a3a/EnvDTE.dll
RedGate.SQLPrompt.CommonUI
Assembly Version: 3.0.0.868
Win32 Version: 3.0.0.868
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.SQLPrompt.CommonUI.DLL
RedGate.Licensing.Client
Assembly Version: 1.3.0.25
Win32 Version: 1.3.0.25
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.Licensing.Client.DLL
RedGate.SQL.Shared
Assembly Version: 5.3.0.1
Win32 Version: 5.3.0.1
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.SQL.Shared.DLL
RedGate.Licensing.Helper
Assembly Version: 1.3.0.25
Win32 Version: 1.3.0.25
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.Licensing.Helper.DLL
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
Microsoft.SqlServer.Management.Reports
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.Reports.DLL
RedGate.SQLPrompt.vsmso
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.SQLPrompt.vsmso.DLL
RedGate.SqlPrompt.Engine
Assembly Version: 3.0.0.868
Win32 Version: 3.0.0.868
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.SqlPrompt.Engine.DLL
EnvDTE80
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.867 (vsvista.050727-8600)
CodeBase: file:///C:/Windows/assembly/GAC/EnvDTE80/8.0.0.0__b03f5f7f11d50a3a/EnvDTE80.dll
RedGate.SqlPrompt.Engine.Gatekeeper
Assembly Version: 3.0.0.868
Win32 Version: 3.0.0.868
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.SqlPrompt.Engine.Gatekeeper.DLL
Microsoft.VisualStudio.TextManager.Interop
Assembly Version: 7.1.40304.0
Win32 Version: 7.0.4054
CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.TextManager.Interop/7.1.40304.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.TextManager.Interop.dll
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
RedGate.Shared.Utils
Assembly Version: 5.3.0.1
Win32 Version: 5.3.0.1
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.Shared.Utils.DLL
RedGate.SQLCompare.Engine
Assembly Version: 5.8.0.59
Win32 Version: 5.8.0.59
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.SQLCompare.Engine.DLL
ObjectExplorer
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/ObjectExplorer.DLL
SqlMgmt
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/SqlMgmt.DLL
ConnectionDlg
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/ConnectionDlg.DLL
Microsoft.VisualStudio
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.867 built by: vsvista
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio/2.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.dll
Microsoft.VisualStudio.Shell
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.867 (vsvista.050727-8600)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Shell/2.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.dll
Microsoft.VisualStudio.Shell.Interop.8.0
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.867 (vsvista.050727-8600)
CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Shell.Interop.8.0/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.Interop.8.0.dll
System.Drawing.Design
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing.Design/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.Design.dll
Microsoft.VisualStudio.Designer.Interfaces
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Designer.Interfaces/1.0.5000.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Designer.Interfaces.dll
Microsoft.SqlServer.RegSvrEnum
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.RegSvrEnum/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.RegSvrEnum.dll
Microsoft.SqlServer.Smo
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Smo/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.Smo.dll
Microsoft.NetEnterpriseServers.ExceptionMessageBox
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.NetEnterpriseServers.ExceptionMessageBox/9.0.242.0__89845dcd8080cc91/Microsoft.NetEnterpriseServers.ExceptionMessageBox.dll
Microsoft.SqlServer.CustomControls
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.CustomControls/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.CustomControls.dll
Accessibility
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
Microsoft.SqlServer.ConnectionInfo
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.ConnectionInfo/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.SmoEnum
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SmoEnum/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.SmoEnum.dll
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
System.Transactions
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
System.EnterpriseServices
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
Microsoft.SqlServer.SqlEnum
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SqlEnum/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.SqlEnum.dll
Microsoft.SqlServer.BatchParser
Assembly Version: 9.0.242.0
Win32 Version: 2005.090.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_32/Microsoft.SqlServer.BatchParser/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.BatchParser.dll
msvcm80
Assembly Version: 8.0.50727.5219
Win32 Version: 8.00.50727.867
CodeBase: file:///C:/Windows/WinSxS/x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.5219_none_d088f566442eca90/msvcm80.dll
ObjectExplorerReplication
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1399.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/ObjectExplorerReplication.DLL
System.Management
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Management/2.0.0.0__b03f5f7f11d50a3a/System.Management.dll
SQLEditors
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Program%20Files/Microsoft%20SQL%20Server/90/Tools/Binn/VSShell/Common7/IDE/SQLEditors.DLL
Microsoft.SqlServer.GridControl
Assembly Version: 9.0.242.0
Win32 Version: 9.00.3042.00
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.GridControl/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.GridControl.dll
RedGate.SQLCompare.ASTParser
Assembly Version: 5.8.0.59
Win32 Version: 5.8.0.59
CodeBase: file:///C:/Program%20Files/Red%20Gate/SQL%20Prompt%203/RedGate.SQLCompare.ASTParser.DLL
Microsoft.VisualStudio.Package.LanguageService
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.867 (vsvista.050727-8600)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Package.LanguageService/2.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Package.LanguageService.dll
dofika1r
Assembly Version: 9.0.242.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
1r8ohz09
Assembly Version: 9.0.242.0
Win32 Version: 2.0.50727.312 (rtmLHS.050727-3100)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Comments

  • Options
    Bart ReadBart Read Posts: 997 Silver 1
    Hi there,


    Sorry to see you're having problems. Can you provide a little more information please? What service pack version do you have installed on SQL Server 2005? Are there any particular special settings on your database (e.g. compatibility mode)? Are you logging in with dbo privileges or not? Can you run SQL Compare 5 on the database with the same login credentials?

    Sorry for the barrage of questions but at the moment I'm afraid we're at a loss.


    Thanks,
    Bart
    Bart Read
    Principal Consultant
    bartread.com Ltd
  • Options
    On the Server: Microsoft SQL Server 2005 - 9.00.2047.00 (Intel X86) Apr 14 2006 01:12:25 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 1)

    Client Info: Microsoft SQL Server Management Studio 9.00.3042.00
    Microsoft Analysis Services Client Tools 2005.090.3042.00
    Microsoft Data Access Components (MDAC) 6.0.6000.16386 (vista_rtm.061101-2205)
    Microsoft MSXML 3.0 4.0 5.0 6.0
    Microsoft Internet Explorer 7.0.6000.16386
    Microsoft .NET Framework 2.0.50727.312
    Operating System 6.0.6000

    I'm not an Admin on this particular server and so the information that I have is sparse at best... (It's a little after 3am here so I cannot get answers from the team that maintains this server at the moment) The SQL Compare menu option is disabled. As more information comes to me... I'll share.
    Are dbo permissions required for SQL Prompt to function properly?
  • Options
    Bart ReadBart Read Posts: 997 Silver 1
    Aha! Yes, that's why: we use the SQL Compare back end to retrieve meta-data, which saved us a lot of time. Unfortunately one of the side effects is that generally you do need dbo access since we read a lot of information from system tables (and in fact much of the information is pulled directly from the SQL definition of many database objects) that is not always visible to other users.

    You can be nice to your DBA and ask if he'll do the following for you:

    GRANT VIEW DEFINITION TO [{you}]

    This will grant you view definition permissions on the entire database, but you won't actually be able to get at the data in any tables/views you don't have permissions for.

    The following extract comes from SQL Server books online:

    "The VIEW DEFINITION permission lets a user see the metadata of the securable on which it is granted. However, VIEW DEFINITION permission does not confer access to the securable itself. For example, a user that is granted only VIEW DEFINITION permission on a table can see metadata related to the table in the sys.objects catalog view. However, without additional permissions, the user cannot read data from the table."

    Please note that this fix will ONLY work for SQL Server 2005, not SQL Server 7 or 2000.

    Hope that helps.


    Thanks,
    Bart
    Bart Read
    Principal Consultant
    bartread.com Ltd
Sign In or Register to comment.