There is a class with a Type property,
[Serializable]
public class MeasureTask
{
private Type _typeToStore;
public MeasureTask()
: this(null)
{}
public virtual Type TypeToStore
{
get { return _typeToStore; }
set { _typeToStore= value; }
}
}
FluentNHibernate mapping for this class to MSSQL DB.
public class MeasureTaskMap : SubclassMap<MeasureTask>
{
public MeasureTaskMap()
{
Map(x => x.TypeToStore);
}
}
By default, this mapping stores the AssemblyQualifiedName
of the Type
as a string
in the db. For Example:
TopNamespace.SubNameSpace.MeasureTask, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
Now, when the assembly is compiled to a higher version, for example,
TopNamespace.SubNameSpace.MeasureTask, MyAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
Then Nhibernate tries to load Type from assembly Version=1.0.0.0
which is stored in the database. But the current type has been changed to Version=2.0.0.0
and this will result in TypeNotFoundException
.
Now, how to get around this problem. I do not want to manually strip off the Version Information from AssemblyQualifiedName, since it creates overhead. Is there anyother standard way to do this ? Because, there are many classes like this to be mapped and this is becoming a breaking issue.