1

(website | windows)アプリとdll(classlibrary)があります。dllでroot(website | windows)設定ファイルのパスを取得したい。

別のassembly.getでConfigurationManager.OpenExeConfigurationを試しましたが、常にdll構成パスが指定されています。

ありがとう

4

1 に答える 1

0

こんにちはこれを見つけました、そしてそれはうまくいきます

 Configuration config;

        if (System.Web.HttpContext.Current != null &&
            System.Web.HttpContext.Current.Request.PhysicalPath.Equals(String.Empty) == false)
        {
            config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpRuntime.AppDomainAppVirtualPath);
        }
        else
        {
            config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        }

基本的に、Webサイトの場合はweb.configを取得し、Windowsアプリの場合はapp.exe.configを取得します。

于 2012-04-12T12:35:15.417 に答える