无法编译映射文档,无法实例化方言类Nhibernate.Dialect.MsSql2008Dialect

时间:2011-07-22 15:35:29

标签: c# .net nhibernate

我正在使用带有NHibernate 3.2.0.GA的Visual Studio 2010,我有一个带有以下Web.Config文件的Web应用程序:

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <configSections>
    <section name="hibernate-configuration"
             type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory name ="Nhibernate.Test">
      <property name="connection.driver_class">
                NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">
        Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Mahshid\Desktop\BugTracker\BugTracker\App_Data\BugTrackerDB.mdf;
        Integrated Security=True;User Instance=True
      </property>
      <property name ="adonet.batch_size">10</property>
      <property name="show_sql">true</property>
      <property name="dialect">Nhibernate.Dialect.MsSql2008Dialect</property>
      <property name="command_timeout">60</property>
      <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,
                                                  NHiberante.ByteCode.LinFu</property>
    </session-factory>
  </hibernate-configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
</configuration>

我在vs2010中添加了我的sql数据库作为本地数据库,我也有两个nhibernate hbm.xml文件,如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   namespace="BugTracker.Model"
                    assembly ="BugTracker">
  <class name="Bug" table ="Bugs" lazy="false">

    <id name ="BugId" column ="BugId" type="int"
         unsaved-value="0">
      <generator class="native"/>
    </id>

    <property name="Desc" column="Description"/>

    <property name="Fixed" column ="Fixed"/>

    <many-to-one  name="Application"
                  class="Application"
                  column="ApplicationId"
                  cascade="all"
                  not-null="true"/>
  </class>
</hibernate-mapping>

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="BugTracker.Model"
                   assembly="BugTracker">
  <class name="Application" table="Applications" lazy="false">
    <id name="ApplicationId" column ="ApplicationId" type="int" unsaved-value ="0">
      <generator class ="native"></generator>
    </id>

    <property name ="Name" column="Name"/>

    <component access ="field.camelcase-underscore" name ="Developer"
               class="Developer">
      <property access ="field.camelcase-underscore" 
                column ="DeveloperFirstName" name="FirstName"/>
      <property access ="field.camelcase-underscore" 
                column="DeveloperLastName" name="LastName"/>
    </component>

    <bag cascade="all-delete-orphan"
          inverse ="true"
          name ="Bugs"
          lazy="false"
          access ="field.camelcase-underscore">
      <key column ="ApplicationId"/>
      <one-to-many class ="Bug"/>
    </bag>

  </class>
</hibernate-mapping>

我将它们设置为嵌入式资源,请相信我,但我在以下代码部分中得到了例外:

private static void Init()
{
    NHibernate.Cfg.Configuration config;

    config = new NHibernate.Cfg.Configuration();
    config.AddAssembly("BugTracker");
    config.Configure();

    _SessionFactory = config.BuildSessionFactory();
}

有了这条消息:

Could not compile the mapping document: BugTracker.Model.Bug.hbm.xml

内部异常消息:

Could not instantiate dialect class Nhibernate.Dialect.MsSql2008Dialect

我知道这是初学者的问题,但我只是个新手!但我很感激你的想法...

1 个答案:

答案 0 :(得分:1)

方言名称不应该是NHibernate.Dialect.MsSql2008Dialect吗?我的意思是H必须是资本?