TypeConverter not serializable

Posts   
 
    
Dave Erwin
User
Posts: 12
Joined: 04-Oct-2010
# Posted on: 20-Jan-2011 17:46:29   

This is an oddball question but I'm going to throw it out here to see if I'm missing a workaround.

I am trying to serialize my NHibernate configuration to a file to improve startup time. This is the link to Ayende's article that referred to the technique.

http://msdn.microsoft.com/en-us/magazine/ee819139.aspx

The problem I'm having is I am using type converters in LLBLGen. I added the serializable attribute to the converters to see how far I could get. The binaryformatter fails because System.ComponentModel.TypeConverter is not serializable.

As far as I can tell the only alternative is to remove the type converters from the NHibernate side of things and handle the conversion in my DTOs.

Has anyone else run into this? Am I missing something?

Thanks,

Dave Erwin

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 20-Jan-2011 22:26:41   

I can't find anyone else having the same issue, but as our support for Nhibernate is fairly recent that doesn't surprise me a lot simple_smile

The only thing I can think to try is to use a type converter of your own that inherits from the existing one, and provide your own implementation of ISerializable - you'd need to find some way to serialize and deserialze the state of the type converter in there...?

Matt

Dave Erwin
User
Posts: 12
Joined: 04-Oct-2010
# Posted on: 21-Jan-2011 14:44:17   

Thanks. That's what I was thinking as well. I ended up pulling the type converters out and using AutoMapper to do the conversion when it moves the entity into my business class. It makes the queries more database-centric but other than that it works.

I just wanted to make sure that I wasn't missing something simple. The reason for serializing is the session factory build takes between 5.5 and 6 seconds normally, when loading from a serialized file it's down to under 2. This is a winforms app so startup is more noticeable than a service.

At some point the data access may move to a service which should take care of it as well.

Dave (E)