-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Serialization/Deserialization of an ISession instance
PostPosted: Thu Dec 08, 2005 9:53 pm 
Hello,

Has anyone tried serializing an ISession instance with a BinaryFormatter, writing to persistent storage, and then opening and deserializing from a different process?

Sergey suggested that we look at the test suites because deserialization works, and I was able to duplicate the success of the test if serialization/deserialization occurred from the same process. But if I tried one from one process and one from another process, I get an exception. The exception is as follows:

System.Runtime.Serialization.SerializationException was unhandled
Message="The object with ID 4 implements the IObjectReference interface for which all dependencies cannot be resolved. The likely cause is two instances of IObjectReference that have a mutual dependency on each other."
Source="mscorlib"
StackTrace:
at System.Runtime.Serialization.ObjectManager.GetCompletionInfo(FixupHolder fixup, ObjectHolder& holder, Object& member, Boolean bThrowIfMissing)
at System.Runtime.Serialization.ObjectManager.CompleteObject(ObjectHolder holder, Boolean bObjectFullyComplete)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at Console_Application.Program.readFromDisk() in E:\Abe's Documents\Visual Studio 2005\Projects\Apprenda Services\Architectural Tests\Session Serialization.root\Session Serialization\Console Application\Program.cs:line 140
at Console_Application.Program.Main(String[] args) in E:\Abe's Documents\Visual Studio 2005\Projects\Apprenda Services\Architectural Tests\Session Serialization.root\Session Serialization\Console Application\Program.cs:line 20
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


Any ideas why this happens and if there is a way to fix it? Thanks.


Top
  
 
 Post subject: Just to clarify
PostPosted: Fri Dec 09, 2005 8:06 am 
As a clarification, the exception is thrown if I serialize in one process, and then try and deserialize the session from another process. Specifically, I run the serialization of a disconnected session, store it. Run another console application to retrieve and deserialize the data, and then I get that pretty exception.


Top
  
 
 Post subject:
PostPosted: Fri Dec 09, 2005 9:20 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
First, the only class implementing IObjectReference in NH is the session factory (SessionFactoryImpl). I looked at the code now, and for the session factory to be deserialized correctly across AppDomains you have to give it a name (use <session-factory name="somename"> to configure). I don't understand why the mutual dependency error is occuring though. Try enabling debug logging for NH, maybe you'll find some hints.


Top
 Profile  
 
 Post subject: Logging
PostPosted: Fri Dec 09, 2005 10:15 am 
Thanks for the tip, I'll turn on debugging tonight and look into it some more


Top
  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:47 pm 
Newbie

Joined: Fri Mar 03, 2006 3:36 pm
Posts: 9
For posterity, here are some observations from a non-expert:

Since the session factory is (apparently) not serialized, the session factory must have been created (e.g. NHibernate.Cfg.Configuration.BuildSessionFactory()) in the deserialization process before deserializing. As noted above, the deserialization process’ factory must have the same name as the factory when the session was serialized. One way to do this is:

<add key="hibernate.session_factory_name" value="SessionFactory.Name"/>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.