Print Page | Close Window

An item with the same key has already been added.

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4563
Printed Date: 19-May-2024 at 3:38pm


Topic: An item with the same key has already been added.
Posted By: BillG
Subject: An item with the same key has already been added.
Date Posted: 14-Oct-2013 at 3:13am
I am using Devforce 2010 6.1.15 with Intersoft UI Controls to create a WPF app. Prior to the middle of the day yesterday my application was working just fine, reading and processing data. Last night i was working on the code and built the latest version and started it up in Visual Studio 2012 using .net 4.0. As soon as i entered the username and password in the login window and called my ValidateLogin routine, I received the above error. Prior to this call there is no data call to retreive data so i know i cannot have a duplicate key value in the cache. So I commented out the call to validate the login. I ran the program again. The very next call to my Repository which is using my entity manager to call an ExecuteQuery I get the above error. I commented out the call to that line. The next call to my repository and a line using the entity manager to execute a query also caused that error. All my calls to my repository class and then any call to the entity manager and trying to run a query i get that error message.
 
In design mode, I can connect to the database and see my model on the screen. I see my entities in the model browser. Validate the model produces no errors. I can refresh the model from the database.
 
Any suggestions? I am out of ideas. My query strategy is set to normal. As i said it was working fine and then this occured. Could my domain model be corrupted? Obvkously every call to retrieve data in a query can't be multiple keys in the cache. So i am assuming this can be a spurious error and refer to some other problem.
 
Bill
 
 



Replies:
Posted By: kimj
Date Posted: 14-Oct-2013 at 10:31am
DevForce will only throw this exception if an entity key already exists in cache.  I can't think why every query for any type would suddenly start throwing this error.  To diagnose this I'd enable breaking on all CLR exceptions so that you'll get a popup for all first chance exceptions.  You'll have to walk through some spurious exceptions to get to the point where this exception is thrown, but you should then have a better idea of where in your code the problem starts.


Posted By: BillG
Date Posted: 14-Oct-2013 at 11:05am
It had to be a corrupted model. I went back to a backup from the previous day and everything is fine.
 
Bill
 



Print Page | Close Window