Red Gate forums :: View topic - Error while calling BuildFromDifferences (key not present)
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK 10
SQL Comparison SDK 10 forum

Error while calling BuildFromDifferences (key not present)

Search in SQL Comparison SDK 10 forum
Post new topic   Reply to topic
Jump to:  
Author Message
JacobEwald



Joined: 08 Nov 2013
Posts: 3

PostPosted: Wed Nov 13, 2013 4:28 pm    Post subject: Error while calling BuildFromDifferences (key not present) Reply with quote

I'm getting the following exception while calling BuildFromDifferences:
Code:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at #8rg.#wvg..ctor(Permissions permissions, Permissions targetPermissions, Options options)
   at RedGate.SQLCompare.Engine.Permissions.#Ghh(SQLScriptBuilder #wUrc, Options #5OPb, Permissions #vUrc, Boolean #yUrc, Boolean #zUrc, String #xUrc, Boolean& #AUrc)
   at RedGate.SQLCompare.Engine.Work.#gQh(Options #5OPb, SQLScriptBuilder #wUrc, #yvg #mXrc, Boolean #yUrc)
   at RedGate.SQLCompare.Engine.Work.GenerateSql(Differences differences, Difference onlyDifferenceToInclude, Options options, Boolean runOnTwo)
   at RedGate.SQLCompare.Engine.Work.BuildFromDifferences(Differences differences, Difference onlyDifferenceToInclude, Options options, Boolean runOnTwo)
   at RedGate.SQLCompare.Engine.Work.BuildFromDifferences(Differences differences, Options options, Boolean runOnTwo)


I'm using a snapshot created by the same version of the SDK to push the changes to 3 test databases. The problem only happens on 1 of the 3. The other weird thing is that I can use the exact same snapshot and push to the failing database using the SQL Compare UI and it works just fine. It seems to only be an issue with the SDK. I'm hoping someone can give me some direction on fixing this problem, thanks!
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6644

PostPosted: Fri Nov 15, 2013 9:29 am    Post subject: Reply with quote

Hello,

Usually this sort of thing is caused by permissions. You may be using a different account when running the SDK app, so check the connection properties. If you set the ConnectionProperties to use SA and it works, that's definitely the problem.

If you need to narrow it down to a specific object, you can debug your app - when the exception breaks into the debugger, you can have a look at the locals and see if you can find the name of a SQL object (they almost always have brackets in the name).

Hope this helps.
Back to top
View user's profile Send private message
JacobEwald



Joined: 08 Nov 2013
Posts: 3

PostPosted: Mon Nov 18, 2013 3:03 pm    Post subject: Reply with quote

I'm using the SA account for generating and publishing the snapshot, and it fails when running through SDK, but succeeds when running through the UI.

When I debug the app and it throws the exception, I'm not sure exactly what I'm looking for in the locals. The Work object has an ExecutionBlock that looks correct, so it seems to have detected the changes without any problem, but the exception still throws.
Back to top
View user's profile Send private message
JacobEwald



Joined: 08 Nov 2013
Posts: 3

PostPosted: Mon Nov 18, 2013 3:14 pm    Post subject: Reply with quote

Found it!

It was one of 2 changes I made. There was a role that needed to own a schema, and a user needed to be added to that role. I did those two things manually though SQL Management Studio. The next time I ran the SDK app it succeeded without throwing that exception.

I would hope that this exception would be handled in a future version, but for now I'll know how to fix it if it comes up again.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6644

PostPosted: Mon Nov 18, 2013 4:45 pm    Post subject: Reply with quote

It would be better if this code was more graceful, but in the meantime, insufficient permissions will result in unhelpful error messages that would require some code debugging.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group