日期:2014-05-18  浏览次数:21175 次

nhibernate Resource not found: ConsoleApplication1.Customer.hbm.xml
Configuration config = new Configuration();
  config.AddClass(typeof(ConsoleApplication1.Customer));
的时候提示 Resource not found: ConsoleApplication1.Customer.hbm.xml
app.config
XML code
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>
  <hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
    <session-factory>
      <property name="connection.provider">
        NHibernate.Connection.DriverConnectionProvider
      </property>
      <property name="dialect">
        NHibernate.Dialect.MySQLDialect
      </property>
      <property name="query.substitutions">hqlFunction=SQLFUNC</property>
      <property name="connection.driver_class">
        NHibernate.Driver.MySqlDateDriver
      </property>
      <property name="connection.connection_string">
        Database=mytestdatabase;Data Source=localhost;User Id=root;Password=routing
      </property>
      <property name="show_sql">false</property>
      <mapping assembly="ConsoleApplication1"/>
    </session-factory>

  </hibernate-configuration>
 </configuration>


------解决方案--------------------
程序中用到了资源文件中的hbm.xml,你机器上没有
------解决方案--------------------
要将hbm.xml文件设为嵌入式资源才行(VS中在hbm.xml文件上右键->属性,在属性窗口,将“生成操作”改为“嵌入式资源”)
------解决方案--------------------
探讨
要将hbm.xml文件设为嵌入式资源才行(VS中在hbm.xml文件上右键->属性,在属性窗口,将“生成操作”改为“嵌入式资源”)