Item has already been added Exception ......

Hi

I was working happily with some web services... getting data from the web services binding them to grids and all that cool stuff... when I get this exception....

"
  -----------------------  Inner Exception Details 
 Message: Item has already been added. Key in dictionary: 'Java:com.some name.model:BaseModel'  Key being added: 'Java:com.some name.model:BaseModel'
 Stack Trace:    at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
   at System.Collections.Hashtable.Add(Object key, Object value)
   at System.Xml.Serialization.XmlSerializationReader.AddReadCallback(String name, String ns, Type type, XmlSerializationReadCallback read)

"

Now I had solved it before but being confident on my memory powers refused to blog it..Goggling dint help either and after 5 minutes I realized what I had done to fix this..So in case I don't forget it and also to help people out there I am blogging it enough said.. the solution is quite simple...

You need to turn off Autogeneration of Serialization assemblies in Compile Options in Visual Studio...

  1. Go To Project (Right Click) --> Properties 
  2. Choose Compile tab on left
  3. Choose Advanced Compile options by clicking the button
  4. If "Generate Serialization assemblies" is set to "Auto" turn it to "Off". If it does not have "Auto" then I am sorry

try running your app/site now and see if it solves the problemmm....

I remember reading that AutoGeneration of Serialization assemblies might help in optimizing some serialization/Deserialization but yet to see some substantial proof for the same...

So I am going to go with the "Off"option for now....

HTH
Hari

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.