(website | windows)アプリとdll(classlibrary)があります。dllでroot(website | windows)設定ファイルのパスを取得したい。
別のassembly.getでConfigurationManager.OpenExeConfigurationを試しましたが、常にdll構成パスが指定されています。
ありがとう
こんにちはこれを見つけました、そしてそれはうまくいきます
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を取得します。