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...
- Go To Project (Right Click) --> Properties
- Choose Compile tab on left
- Choose Advanced Compile options by clicking the button
- 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


Comments