I've done a little test (yes, in the same application), trying to serialize (XMLSerializer) a lazyLoading object that contains inner objects. The exception I got is
System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: CProxyTypeMyNamespaceMyClass_NHibernate_ProxyINHibernateProxy_System_Runtime_SerializationISerializable2 cannot be serialized because it does not have a parameterless constructor.
at System.Xml.Serialization.TypeDesc.CheckSupported()
at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
...
Trying to work with BinaryFormatter serializes ok, but throws an exception when deserializing
NHibernate.LazyInitializationException: Could not initialize proxy - no Session.
at NHibernate.Proxy.LazyInitializer.Initialize() in c:\net\nhibernate\nhibernate\src\NHibernate\Proxy\LazyInitializer.cs:line 77
at NHibernate.Proxy.LazyInitializer.GetImplementation() in c:\net\nhibernate\nhibernate\src\NHibernate\Proxy\LazyInitializer.cs:line 240
at NHibernate.Proxy.CastleLazyInitializer.Intercept(IInvocation invocation, Object[] args) in c:\net\nhibernate\nhibernate\src\NHibernate\Proxy\CastleLazyInitializer.cs:line 59
at CProxyTypeMyNamespaceMyClass_NHibernate_ProxyINHibernateProxy_System_Runtime_SerializationISerializable2.ToString()
...
As I said... I need a solution for lazyLoading (when lazy = false everything is fine, but the option is not acceptable)
Thx in advance,
Sirin
|