Actually the Class5 is not used in a list but it has properties of type 
List. So we are trying to deserialize as an object.
I have also posted the same question 
HERE<http://stackoverflow.com/questions/16642466/unable-to-cast-object-of-type-nhibernate-collection-generic-persistentgenericba/16655955>with
 an example. Could you please check it?

On Sunday, May 19, 2013 11:26:09 PM UTC-4, Murali Mohan wrote:

> I am trying to load the domain class by deserializing an xml file. So I 
> have used List in the domain class. But when I try to save the object using 
> Session object then it is failing with exception "Unable to cast object of 
> type 
> 'NHibernate.Collection.Generic.PersistentGenericBag`1[MyFirstMapTest.Class5]' 
> to type 'System.Collections.Generic.List`1[MyFirstMapTest.Class5]'." This 
> issue was posted in some of the previous discussion and the answer was to 
> use use IList<int> instead of List<int>(
> http://stackoverflow.com/questions/1638593/unable-to-cast-object-of-type-nhibernate-collection-generic-persistentgenericbag
> )
>  
> But, If I use IList then I am unable to Deserialize the xml in to Domain 
> class. It gives another error "Cannot serialize member xxxxx of type 
> System.Collections.Generic.IList`1[[xxxxxxxxxx, Examples, Version=1.0.0.0, 
> Culture=neutral, PublicKeyToken=null]] because it is an interface." 
> I have tried to use PersistentGenericBag instead of List but 
> PersistentGenericBag is not serializable. So Deserialization is not working.
>  
> How can I resolve this issue? Thank you for looking at this issue.
>  
> Regards,
> Murali
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fluent-nhibernate+unsubscr...@googlegroups.com.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to