Speeding Up NHibernate Startup Time

Posted by Ricardo Peres on ASP.net Weblogs See other posts from ASP.net Weblogs or by Ricardo Peres
Published on Wed, 31 Mar 2010 13:47:00 GMT Indexed on 2010/03/31 13:53 UTC
Read the original article Hit count: 431

Filed under:
|

One technique I use and posted on the NHUsers mailing list consists in serializing a previously-configured Configuration to the filesystem and deserializing it on all subsequente starts of the application:

Configuration cfg = null;
IFormatter serializer = new BinaryFormatter();

//first time
cfg = new Configuration().Configure();

using (Stream stream = File.OpenWrite("Configuration.serialized"))
{
	serializer.Serialize(stream, configuration);
}

//other times
using (Stream stream = File.OpenRead("Configuration.serialized"))
{
	cfg = serializer.Deserialize(stream) as Configuration;
} 

Check it out for yourselves.

Bookmark and Share

© ASP.net Weblogs or respective owner

Related posts about .NET

Related posts about nhibernate