Hi Klaus,
Using lazy=false is not a good solution to me. I just want to load what I will use. If there is a collection not initialized I would like to be null or Count=0.
I'm still thinking write a function that runs through the object graph and initialize all properties and lists. There must be an easy way to return the objects like they were designed.
I've done a test. I really need Nhibernate.dll, Log4net.dll and Castle.DynamicProxy.dll. My business objects don't have reference to them but I still have to add them in my client project.
The worst of all is that I am receiving this error when the server sends data to client. Without changing any line in the code, just rebuilding the projects 2 or 3 times, everything works fine. I didn't have this error when I was using specific DTO's.
Quote:
Exception has been thrown by the target of an invocation.
Server stack trace:
em System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
em System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)
em System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
em System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
em System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
em System.Runtime.Serialization.ObjectManager.DoFixups()
em System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
em System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
em System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.UnsafeDeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage)
em System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryResponseMessage(Stream inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
em System.Runtime.Remoting.Channels.BinaryClientFormatterSink.DeserializeMessage(IMethodCallMessage mcm, ITransportHeaders headers, Stream stream)
em System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
em System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
em System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
em Noventa.Regente.Modulo.Contratos.Controle.ICSocioContrato.ListarSocios(Int64 contrato_id)
em Noventa.Regente.Modulo.Contratos.Tela.FSocioContrato.ListarSocios() na D:\Fontes\regente.net\cliente\Contrato.Tela\FSocioContrato.cs:linha 165
em Noventa.Regente.Modulo.Contratos.Tela.FSocioContrato.FSocioContrato_Load(Object sender, EventArgs e) na D:\Fontes\regente.net\cliente\Contrato.Tela\FSocioContrato.cs:linha 93
The object of type 'System.Decimal' can't be converted in type 'System.Int64'.
em System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
em System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)
em System.Runtime.Serialization.FormatterServices.SerializationSetValue(MemberInfo fi, Object target, Object value)
em System.Runtime.Serialization.FormatterServices.PopulateObjectMembers(Object obj, MemberInfo[] members, Object[] data)
em Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateClassProxy(SerializationInfo info, StreamingContext context)
em Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateProxy(SerializationInfo info, StreamingContext context)
em Castle.DynamicProxy.Serialization.ProxyObjectReference..ctor(SerializationInfo info, StreamingContext context)
I found this post at hibernate forum with the context
http://forum.hibernate.org/viewtopic.php?t=964452&highlight=dto
Thank you