开发者

Finding app config file from assembly

I'm using Nini to read config throughout the app. I'm running into a problem in assemblies where I want to read the main applications config file (regardless of web.config or app.config).

This is standard way:

private static IConfigSource source = new DotNetConfigSource(DotNetConfigSource.GetFullConfigPath());

The problem in the case of a开发者_JAVA技巧ssemblies is that DotNetConfigSource.GetFullConfigPath() returns "assembly.dll.config", not "app.exe.config" or "web.config".

What to do, what to do?


System.Configuration.Configuration config =
                ConfigurationManager.OpenExeConfiguration(
                ConfigurationUserLevel.None);

string configPath = config.FilePath;

private static IConfigSource source = new DotNetConfigSource(configPath);

Try that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜