An item with the same key has already been added.
sidharthnayyar
Posts: 8
Dear All,
I've got SQL Source Control 3.0.6.25 but only today I've started getting a strange error on one of my version controlled databases (SVN btw).
Any ideas how I can fix this?
Kind regards
Sidharth
I've got SQL Source Control 3.0.6.25 but only today I've started getting a strange error on one of my version controlled databases (SVN btw).
Any ideas how I can fix this?
Kind regards
Sidharth
RedGate.SQLSourceControl.Engine.SqlCompareException: An item with the same key has already been added. ---> System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at RedGate.SQLCompare.Engine.KeyedCollection`1.Add(T value)
at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.#5Ih(Constraint #ZKPb, Table #fvPb, Boolean #W1rc, AlterTable #X1rc)
at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.#4Ih(Element #wpUb)
at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.#SHh(AST #iAPb)
at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.#SHh(AST #iAPb)
at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.VisitNode(Element node, AnalysisProvider`1 provider)
at RedGate.SQLCompare.Rewriter.Analysis.Analyser`1.#hbh(Element #fpl)
at RedGate.SQLCompare.Rewriter.Analysis.Analyser`1.Analyse(IEnumerable`1 elements)
at #Eyg.#Gyg.#CGh(FileInfo #mDk)
at #Eyg.#Gyg.#vl(IEnumerable`1 #rXrc)
at RedGate.SQLCompare.Engine.Database.Register(String path, ScriptDatabaseInformation dbinfo, Options options, IEnumerable`1 filesToUse, IReadFromFolderCache cache)
at RedGate.SQLCompare.Engine.Database.Register(String path, ScriptDatabaseInformation dbinfo, Options options, IEnumerable`1 filesToUse)
at RedGate.SQLCompare.Engine.Database.Register(String path, ScriptDatabaseInformation dbinfo, Options options)
at #qlhb.#L3c.#y25.#nKcb()
at #GWeb.#7Jf.#gKf(Action )
--- End of inner exception stack trace ---
Server stack trace:
at #GWeb.#7Jf.#gKf(Action )
at #GWeb.#7Jf.#z21.#rkW()
at RedGate.SQLSourceControl.Engine.SharedUtilsUtils.DoActionWithCancel(ICancellableOperationStatus status, ICancellable cancellable, Action action)
at #GWeb.#7Jf.#jKf(ICancellableOperationStatus , ICancellable , Action )
at #qlhb.#L3c.#l36(String , #x36 , ICancellableOperationStatus )
at #qlhb.#K3c.#83c(String , #O9U , ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks )
at #qlhb.#L3c.#f6c(String , ScriptDatabaseInformation , Options , ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks )
at #GWeb.#WXM.#f6c(String )
at #GWeb.#XXM.#Qy2b()
at #GWeb.#Wheb.#tieb(Func`1 )
at #GWeb.#XXM.#Py2b()
at RedGate.SQLSourceControl.Engine.Cancellables.CancellableUtils.#y21.#RKc()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
at System.Action.EndInvoke(IAsyncResult result)
at RedGate.SQLSourceControl.Engine.Cancellables.CancellableUtils.DoInParallel(ICancellableOperationStatus status, Pair`2[] labelledActions)
at #GWeb.#WXM.#rYM()
at #GWeb.#WXM.#qYM()
at #GWeb.#XXM.#iS()
at #qlhb.#0heb.#l36(String , #1heb , ICancellableOperationStatus )
at #qlhb.#K3c.#83c(String , #O9U , ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks )
at #qlhb.#0heb.#wieb(#L3c , #ZZ7 , #A57 , #tEc , IObjectExplorerStateService , #xHR , #9ynb , #4Ec , #j3l , Options , #quBb , ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks )
at #GWeb.#VXM.#mYM[#NrPb](Func`2 , ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks , IDifferenceSelector )
at #GWeb.#VXM.#jYM(ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks , IDifferenceSelector )
at #GWeb.#4Ec.#7Jc(ICancellableOperationStatus , IReadOnlySourceControlServerCallBacks , IDifferenceSelector )
at #GWeb.#4Ec.#y26.#QB7b(ICancellableOperationStatus )
at RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1.#u36.#k5f()
at RedGate.SQLSourceControl.Engine.Cancellables.CancellableOperationBase.InvokeWithTracker(String featureUsageKey, Action action)
at RedGate.SQLSourceControl.Engine.Cancellables.MutexedCancellableOperation`1.Invoke()
at #eEc.#Qlg.Invoke()
at #JLc.#PLc.#Jfb.#EJf()
at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.Do(Action , Predicate`1 , Boolean )
at RedGate.SQLSourceControl.Engine.SmartAssembly.ExceptionReporting.ErrorReporterBase.DoWithObviousExceptionsRethrowAll(Action action)
at RedGate.SQLSourceControl.CommonUI.Forms.ErrorDialog.DoWithObviousExceptionsRethrowAll(Action action)
at #JLc.#PLc.#CTc(ICancellableOperation`1 , Object )
Comments
There's a few things that can cause this. Usually though, it's because you have duplicate definitions somewhere for one or more objects. This can happen if you have maybe made a backup copy of one of the files in SVN? If you click the "Send error report" option and enter your email address I can see if it contains further information.
The other possibility is when you have objects that differ in name only in whitespace. I think we changed the default to not be a problem any more, but you can double check by running this query:
Any results from that can potentially cause the error as well.
Redgate Software
I've sent the error report to you.
That SQL did return some results but it makes no sense to me!
That's name and id from the result
Thanks
Kind regards
Sidharth
The default behaviour of SQL Source Control used to be (and may still be) that it ignores whitespace, so essentially you end up with two functions being seen as the same thing. That leads to the error.
Do you know if you definitely need all four of those functions? It looks more like one of each is either a typo or created in error... if you can remove the files for the problematic ones from SVN then re-link your database the problem may well go away. I'll keep an eye open for the error report if that refers to different objects though.
Redgate Software
Thanks for the reply. I've not created those functions! That's very strange. I'll see if deleting it from SVN fixes that problem - I have to leave just now though so it'll next week when I check this.
Thanks and kind regards
Sidharth
Redgate Software
I think I've found the problem. I had enabled Change Data Capture and DB Auditing for the database and that must've caused SQL Source Control to stop working. I've removed all objects from SVN, relinked and it's worked. And I've also disabled and removed all CDC objects. Hopefully that should work now.
However, I may need to enable CDC in the future - can you confirm Source Control works with CDC enabled?
Kind regards
Sidharth
More likely is that by clearing up your SVN contents, you've removed whatever rogue file had a duplicate object definition in it.
Redgate Software
Okay, that's good to know. Thanks for all your help.
Kind regards
Sidharth
Thanks!
It's unusual to get this message for something like temporary tablenames like that though; unless those definitions are in their own file or something?
Redgate Software