nhibernate Resource not found: ConsoleApplication1.Customer.hbm.xml

linyefeilyft 2012-07-24 05:22:50
Configuration config = new Configuration();
config.AddClass(typeof(ConsoleApplication1.Customer));
的时候提示 Resource not found: ConsoleApplication1.Customer.hbm.xml
app.config
<?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>
...全文
173 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
happyrain2010 2012-07-25
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]
要将hbm.xml文件设为嵌入式资源才行(VS中在hbm.xml文件上右键->属性,在属性窗口,将“生成操作”改为“嵌入式资源”)
[/Quote]
正确!!!
hustcyb 2012-07-24
  • 打赏
  • 举报
回复
要将hbm.xml文件设为嵌入式资源才行(VS中在hbm.xml文件上右键->属性,在属性窗口,将“生成操作”改为“嵌入式资源”)
linyefeilyft 2012-07-24
  • 打赏
  • 举报
回复
hbm.xml文件是放在根目录下的
linyefeilyft 2012-07-24
  • 打赏
  • 举报
回复
hbm.xml文件

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ConsoleApplication1" assembly="ConsoleApplication1">
<class name="Customer" table="Customer">
<id name="ID" column="id">
<generator class="assigned"/>
</id>
<property name="Address" column="Address" type="String" length="45" />
<property name="Name" column="Name" type="String" length="45" />
</class>
</hibernate-mapping>
bdmh 2012-07-24
  • 打赏
  • 举报
回复
程序中用到了资源文件中的hbm.xml,你机器上没有

110,548

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧