NHibernate:自定义方言-如何在单独的程序集中指定类 [英] NHibernate: Custom Dialect - how to specify the class in a separate assembly

查看:64
本文介绍了NHibernate:自定义方言-如何在单独的程序集中指定类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用NHibernate的项目,并且有一个自定义方言:

I have a project which 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"; } }
    }

我为此课程有一个单独的程序集:Assembly1. Assembly1内置在NHibernate.dll所在的目录中.

I have a separate assembly for this class: Assembly1. Assembly1 is built into the directory where NHibernate.dll is.

在我的cfg文件中添加:

In my cfg file I added:

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

运行我的应用程序时,出现以下错误:

When I run my app 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

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'm sure there is an obvious explanation for this but I'm stuck at the moment - could you help?

问候 泰梅克

推荐答案

<property name="dialect">MyAssembly1.MyDialectClass1, MyAssembly1</property>

这篇关于NHibernate:自定义方言-如何在单独的程序集中指定类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆