.NET 4.0 / SL 4 upgrade error

.NET 4.0 / SL 4 upgrade error

Old forum URL: forums.lhotka.net/forums/t/9108.aspx

normalham2 posted on Friday, June 18, 2010

I have upgraded to the new version of CSLA for Silverlight a few days ago.  I'm getting the following exception we I do a build in Release mode.  If I do a build in Debug mode, I don't get the exception.

I get the following exception:

Message: An item with the same key has already been added.
Stack Trace:    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Csla.Core.FieldManager.FieldDataManager.GetConsolidatedList(Type type)
   at Csla.Core.FieldManager.FieldDataManager.OnSetState(SerializationInfo info, StateMode mode)
   at Csla.Core.MobileObject.Csla.Serialization.Mobile.IMobileObject.SetState(SerializationInfo info)
   at Csla.Serialization.Mobile.MobileFormatter.DeserializeAsDTO(List`1 deserialized)
   at Csla.Serialization.Mobile.MobileFormatter.Deserialize(XmlReader reader)
   at Csla.DataPortalClient.WcfProxy`1.proxy_FetchCompleted(Object sender, FetchCompletedEventArgs e)

So looking at the method that is throwing the exception, I'm really not sure why it is happening.

private static List<IPropertyInfo> GetConsolidatedList(Type type)
      List<IPropertyInfo> result = null;
      if (!_consolidatedLists.TryGetValue(type, out result))
        lock (_consolidatedLists)
          if (!_consolidatedLists.TryGetValue(type, out result))
            result = CreateConsolidatedList(type);
            _consolidatedLists.Add(type, result);
      return result;

Does anyone have any ideas for fixing this?



Jaans replied on Thursday, July 01, 2010

Did you ever find out what the root cause and/or fix is for this?

RockfordLhotka replied on Thursday, July 01, 2010

This sounds exactly like the kind of problem you'd encounter if your PropertyInfo<T> fields are not public.

Copyright (c) Marimer LLC