Can't create new code review response "An entry with the same key already exists."

Jul 1, 2009 at 10:32 AM

 

01/07/2009 09:57:31 System.ArgumentException: An entry with the same key already exists.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
   at TeamReview.UI.CreateWorkItemForm.GetAvailableTeamQueries()
   at TeamReview.UI.CreateWorkItemForm.BindQueries()
   at TeamReview.UI.CreateWorkItemForm..ctor(DTE2 shell, CodeSelection codeSelection)
   at TeamReview.Command.CreateWorkItemCommand.ShowForm()
   at TeamReview.Command.ShowFormCommand.Execute()
   at TeamReview.VSNetAddIn.Connect.ShowAddCodeReviewItemEventHandler(Object commandaBarControl, Boolean& handled, Boolean& cancelDefault).

this is caused by private IDictionary<String, StoredQuery> GetAvailableTeamQueries() in CreateWorkItemForm at line 225-233. I replaced this method as follows:

<snip>


        private IDictionary<String, StoredQuery> GetAvailableTeamQueries()
        {
            StoredQueryCollection sq = TFSService.WorkItemStore.Projects[TFSService.TeamProject.Name].StoredQueries;
            SortedList<string, StoredQuery> sorted = new SortedList<string, StoredQuery>();
            foreach (StoredQuery q in sq) 
                sorted.Add(GetKey(q.Name, sorted), q);

            return sorted;
        }

        private String GetKey(String keyStub, System.Collections.Generic.SortedList<string, StoredQuery> list)
        {
            int unique = 1;
            String theKey = keyStub;
            while (list.ContainsKey(theKey))
            {
                theKey = keyStub + " - " + unique.ToString();
                unique++;
            }

            return theKey;
        }


</snip>

Coordinator
Jul 1, 2009 at 5:32 PM
Hi - Did your TeamProject have a private query with the same name as a public query? If so, this is a known issue that we plan on fixing using a "public" or "private" identifier in the drop down.

Thank you for contacting us with a full debug stack and a solution!
--
JB Brown, Team System MVP

Email  JB@ControlStatements.com
Blog    http://www.ControlStatements.com
Code   http://TeamReview.codeplex.com
Twitter @jbbrown

On Wed, Jul 1, 2009 at 2:32 AM, sammyg <notifications@codeplex.com> wrote:

From: sammyg

 

01/07/2009 09:57:31 System.ArgumentException: An entry with the same key already exists.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
   at TeamReview.UI.CreateWorkItemForm.GetAvailableTeamQueries()
   at TeamReview.UI.CreateWorkItemForm.BindQueries()
   at TeamReview.UI.CreateWorkItemForm..ctor(DTE2 shell, CodeSelection codeSelection)
   at TeamReview.Command.CreateWorkItemCommand.ShowForm()
   at TeamReview.Command.ShowFormCommand.Execute()
   at TeamReview.VSNetAddIn.Connect.ShowAddCodeReviewItemEventHandler(Object commandaBarControl, Boolean& handled, Boolean& cancelDefault).

this is caused by private IDictionary<String, StoredQuery> GetAvailableTeamQueries() in CreateWorkItemForm at line 225-233. I replaced this method as follows:

<snip>


        private IDictionary<String, StoredQuery> GetAvailableTeamQueries()
        {
            StoredQueryCollection sq = TFSService.WorkItemStore.Projects[TFSService.TeamProject.Name].StoredQueries;
            SortedList<string, StoredQuery> sorted = new SortedList<string, StoredQuery>();
            foreach (StoredQuery q in sq) 
                sorted.Add(GetKey(q.Name, sorted), q);

            return sorted;
        }

        private String GetKey(String keyStub, System.Collections.Generic.SortedList<string, StoredQuery> list)
        {
            int unique = 1;
            String theKey = keyStub;
            while (list.ContainsKey(theKey))
            {
                theKey = keyStub + " - " + unique.ToString();
                unique++;
            }

            return theKey;
        }


</snip>

Read the full discussion online.

To add a post to this discussion, reply to this email (TeamReview@discussions.codeplex.com)

To start a new discussion for this project, email TeamReview@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




Jul 1, 2009 at 5:34 PM

Yes. It was a cut and paste of a team query into the private/”my queries” node.

Orbis Investment Advisory Limited is authorised and regulated by the Financial Services Authority.
Reg. No. 2068389. Registered in England. Reg. Office: Orbis House, 5 Mansfield Street, London W1G 9NG. Tel: +44-20-7462-0800.
Coordinator
Aug 4, 2009 at 10:00 PM

This fix was published today in release 1.1.1 - http://teamreview.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27776 

 

Thanks,

JB