Error when comparing: "The given key was not present in ..."
Decorum
Posts: 10 Bronze 2
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
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
Dropping and recreating the role fixed the issue.
Can you check this out please?
Also, the fact that it works in an older version of SQL Compare to me says it is some form of regression...
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.
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.
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()
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 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?
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.