Error when comparing: "The given key was not present in ..."

DecorumDecorum Posts: 10 Bronze 2
edited January 21, 2010 3:27PM in SQL Compare Previous Versions
Hello,

I am using the latest version 8.1.0.360. When comparing two databases, an error occurs during the step "Comparing". The error message displayed in the bottom of the dialog is "The given key was not present in the dictionary."

Tried the same comparison in older version 7.1.0.197 and it works without problems there.

Best regards,
Daniel Stolt

Comments

  • In one similar case, it seems that it was down to one of the database roles being corrupt.

    Dropping and recreating the role fixed the issue.

    Can you check this out please?
  • DecorumDecorum Posts: 10 Bronze 2
    Yes, I read the other thread and tried that before posting. No luck.

    Also, the fact that it works in an older version of SQL Compare to me says it is some form of regression...
  • Could you please run:

    SELECT CAST(0 AS INT) AS ColumnPermissionID, sp.grantee_principal_id as uid, su.name AS UserName,
    OBJECT_NAME(sp.major_id) AS ObjectName,
    SCHEMA_NAME(so.schema_id) AS ObjectOwner,
    1 AS class, sp.type, sp.state,
    so.type AS ObjectType,
    CONVERT(int, null) as columns
    FROM sys.database_permissions AS sp WITH (NOLOCK) INNER JOIN sys.sysusers su WITH (NOLOCK) ON su.uid=sp.grantee_principal_id INNER JOIN sys.objects so WITH (NOLOCK) ON so.object_id=sp.major_id WHERE sp.major_id>0 AND sp.class = 1 AND sp.minor_id = 0 AND (sp.type in ('IN','DL','EX') OR CHARINDEX(sp.type, 'CRFNCRTBCRDBCRVWCRPRBADBCRDFBALOCRRU')%4 > 0) AND so.schema_id IS NOT NULL AND sp.type='VWCT'
    GROUP BY sp.major_id, sp.grantee_principal_id, sp.grantor_principal_id, sp.type, sp.state, so.type, su.name, so.schema_id



    If anything is returned, the problem is that in SQL 2008, we do not support the View Change Tracking user right.
  • DecorumDecorum Posts: 10 Bronze 2
    Ran the query, but it returns nothing.
  • DecorumDecorum Posts: 10 Bronze 2
    You know, if you provided a way to display a stack trace of that exception, perhaps you could actually track it down instead of trying to guess? Just a thought...
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Yes, that would be nice, for a start. There is no foolproof way of tracking down system-level exceptions in SQL Compare, so we usually start with the known issues.

    You can get the stack by looking at the SQL Compare logs using the icon in the upper-left of the window title bar. We probably need the stack, though, because the code is heavily obfuscated and we need to compare the methods on the stack to our obfuscation report.
  • Just to say - if you can get that information, please send it to [email protected] (with subject: F0025768). I have opened a support ticket for this already.
  • DecorumDecorum Posts: 10 Bronze 2
    I've sent the log information in an email as requested. Will post it here too for reference:

    16:16:02.791|Info |Logging |1 |Current Logging levels enabled: Warning,Fatal,Error
    16:16:29.458|Error |SQL Compare UI |1 |Exception in progress dialog
    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    at System.ThrowHelper.ThrowKeyNotFoundException()
    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    at S..ctor(Permissions permissions, Permissions targetPermissions, Options options)
    at RedGate.SQLCompare.Engine.Permissions.a(Permissions , Options )
    at RedGate.SQLCompare.Engine.Schema.Equals(IDatabaseObject target, Options options)
    at RedGate.SQLCompare.Engine.Database.a[a](Differences , IDatabaseObjects`1 , IDatabaseObjects`1 , Options , SQLVersion , Int64 , Int64& , Int32& , L )
    at RedGate.SQLCompare.Engine.Database.CompareWith(Database targetDatabase, Options options, SqlCompareOwnerMappings mappings)
    at ap.DoCompareDatabases()
    at RedGate.Shared.Utils.ProgressTasks.ProgressTask.a()
    at RedGate.Shared.Controls.ProgressDialogEx.e()
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi,

    We have an update to SQL Compare to fix the "key was not present in the dictionary" error when it is caused by a schema or user that has the "View Change Tracking" permission granted or revoked. If you have this problem, please download the updated installation from here:
    http://www.red-gate.com/messageboard/vi ... php?t=9860

    Please be aware that this is not an "official" release and may have unintended side-effects, so do not install the update unless you specifically have the issue mentioned above!
  • I get the same error as that reported by Decorum.
    I ran the TSQL suggested by Chris.Allen on 24 Aug 2009 17:41; no rows were returned.
    Log follows:

    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    at System.ThrowHelper.ThrowKeyNotFoundException()
    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    at S..ctor(Permissions permissions, Permissions targetPermissions, Options options)
    at RedGate.SQLCompare.Engine.Permissions.a(Permissions , Options )
    at RedGate.SQLCompare.Engine.Schema.Equals(IDatabaseObject target, Options options)
    at RedGate.SQLCompare.Engine.Database.a[a](Differences , IDatabaseObjects`1 , IDatabaseObjects`1 , Options , SQLVersion , Int64 , Int64& , Int32& , L )
    at RedGate.SQLCompare.Engine.Database.CompareWith(Database targetDatabase, Options options, SqlCompareOwnerMappings mappings)
    at ap.DoCompareDatabases()
    at RedGate.Shared.Utils.ProgressTasks.ProgressTask.a()
    at RedGate.Shared.Controls.ProgressDialogEx.e()

    Does this indicate that the "key was not present in the dictionary" I am experiencing is caused by a schema or user that has the "View Change Tracking" permission granted or revoked?
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hello,

    The stack trace you have posted is identical to the one that you get if you have the "view change tracking" bug. I'd try the update mentioned in the previous post.
  • has the patch mentioned a couple of post earlier been removed? if so, where can it be found as i have run across the same error. thx!
  • the latest cummulative patch resolves the issue. thanks red-gate support (eddie).
Sign In or Register to comment.