-->
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.  [ 4 posts ] 
Author Message
 Post subject: NHibernate and AppDomain
PostPosted: Wed Jan 14, 2009 6:30 am 
Newbie

Joined: Thu Feb 07, 2008 6:48 am
Posts: 14
Hello,

I'm working on a tool that needs to rebuild it's domain classes on the fly.
I store these classes in: AutoGenerated.dll

My mapping files are being generated on the fly too... and they point to the assembly via: Assembly="AutoGenerated.dll"

I add these mapping files via:

configuration.AddDocument(myDynamicMappingFile);

At this point my application takes the AutoGenerated.dll and the mapping file. From this point. nHibernate holds a reference to the AutoGenerated.dll

And that is my problem... I would like to re-generate the AutoGenerated.dll and re-configure my nhibernate session. But nhibernate is holding my AutoGenerated.dll so I get the error "this file is in use by another..." so I cannot overwrite it.

I heard it would be better to load the AutoGenerated.dll in a separate AppDomain. And do an UnLoad of the AppDomain so I can delete and rebuild my AppDomain on the fly...

Hope you understand what I mean here :-)

Please can anyone give my some hints on this?

Regards!
M


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2009 10:33 am 
Beginner
Beginner

Joined: Thu Oct 26, 2006 4:45 am
Posts: 39
You want to change your mapping file while running your software?

Can you elaborate on that?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 25, 2009 5:44 am 
Newbie

Joined: Sun Jan 25, 2009 4:32 am
Posts: 8
This isn't just an issue with nhibernate. This is how the .Net Framework works. You cannot unload assemblies (dlls) from the default AppDomain. You will need to load the dll in a separate AppDomain. When you want to load a new version of the same dll, you will have to unload the AppDomain as there is no way to unload a single assembly. Once you have this setup you will then have to access to second AppDomain through remoting.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2009 4:47 am 
Newbie

Joined: Thu Feb 07, 2008 6:48 am
Posts: 14
Hello,

Yes I know it is not an nHibernate issue. But I would like to see an example how I can create a second AppDomain, and how to load the nhibernate specific domain .dll in this second AppDomain.

Is there anyone having experience with this issue? Because I often regenerate dynamically some domain objects and I would like to re-load them into nhibernate. But the dll's are 'in use and locked' by the default AppDomain...

Regards!
M


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.