zoukankan      html  css  js  c++  java
  • NHibernate.Cfg.HibernateConfigException

    Exception Details:

    NHibernate.Cfg.HibernateConfigException: An exception occurred during configuration of persistence layer. ---> System.IO.FileNotFoundException: Could not find file 'C:\Windows\system32\Config\hibernate.cfg.xml'.

    Reason:

    By default window services set the default directory to the %WINDIR%$\system32. We need to change out default service's directory to wherever our service running.

    ---Solution 1---

    Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

    ---Solution 2---

    string configPath = ConfigurationManager.AppSettings["HibernateConfigPath"];
    
    string path = configPath;
    
    if (!Path.IsPathRooted(configPath))
    {
      string basedir = AppDomain.CurrentDomain.BaseDirectory;
      path = Path.Combine(basedir, configPath);
    }
    
    //we can get the correct path in 'pathToUse'
  • 相关阅读:
    day22-20180522笔记
    day20-20180517笔记
    day19-20180515笔记
    day18-20180513笔记
    day17-20180510笔记
    day16-20180508笔记
    Python之初识面向对象
    Python之常用模块(2)
    Python之常用模块(1)
    Python之模块与包(下)
  • 原文地址:https://www.cnblogs.com/vincentDr/p/2958070.html
Copyright © 2011-2022 走看看