我的WCF服务库中包含hibernate.cfg.xml,其中包括

BuildAction =内容和
复制到输出目录=始终复制

但是,当我运行该应用程序时,它会引发以下错误:

找不到文件
'C:\Program Files(x86)\DevExpress 2010.2\IDETools\System\CodeRush\Bin\PlugIns\hibernate.cfg.xml'

我不确定为什么要在上述路径而不是运行时bin目录中寻找hibernate.cfg.xml。

仅供引用:我最近安装了DevExpress v10.2,以便在另一个应用程序中使用。

有任何想法吗?

请您参考如下方法:

一种选择是将您的nHibernate配置移至web.config

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> 
  <session-factory> 
    ... 
  </session-factory> 
</hibernate-configuration> 

在您的 configsections部分中添加
<configuration> 
  <configSections> 
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" requirePermission="false" /> 
    ... 
  <configSections> 
<configuration> 

另一个选择是尝试此操作(在wcf中未经测试)
var cfg = new Configuration(); 
cfg.Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"hibernate.cfg.xml")); 


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!