NHibernate: Custom Dialect - how to specify a class in a separate assembly

I have a project that uses NHibernate, and I have a custom dialect:

using System; using System.Collections.Generic; using System.Web; public class NHibernateMySQL5InnoDBDialect : NHibernate.Dialect.MySQL5Dialect { public override String TableTypeString { get { return " ENGINE=InnoDB DEFAULT CHARSET=utf8"; } } } 

I have a separate assembly for this class: Assembly1. Assembly1 is embedded in the directory where NHibernate.dll is located.

In my cfg file, I added:

 <property name="dialect">Assembly1.NHibernateMySQL5InnoDBDialect</property> 

When I run my application, I get the following error:

NHibernate.MappingException: Could not compile the mapping document: XXX.hbm.xml ---> NHibernate.HibernateException: Could not instantiate dialect class Assembly1.NHibernateMySQL5InnoDBDialect ---> System.TypeLoadException: Could not load type Assembly1.NHibernateMySQL5InnoDBDialect. Possible cause: no assembly name specified. at NHibernate.Util.ReflectHelper.TypeFromAssembly (NHibernate.Util.AssemblyQualifiedTypeName name, Boolean throwOnError) [0x00000] in :0

I am sure there is an obvious explanation for this, but I am stuck at the moment - could you help?

Relations Tymek

+2
source share
1 answer
 <property name="dialect">MyAssembly1.MyDialectClass1, MyAssembly1</property> 
+8
source

Source: https://habr.com/ru/post/912624/


All Articles