开发者

asp.net reading config file from class library

Hi I a custom config file which I am having problems reading from a class project开发者_开发技巧, is there a simple way to do this? the path does not seem to be getting picked up in code, where as this works in a web project


I'm going to go out on a limb here and suppose that you are reading .config files from an established path, i.e. the path of your class project. There really isn't enough information in the question, however this looks revealing: the path does not seem to be getting picked up in code, where as this works in a web project. If that is the case, I would suggest you take a look at http://keithelder.net/blog/archive/2007/12/14/How-To-Load-an-Embedded-Resource-From-A-DLL.aspx


The .NET configuration system doesn't natively support class libraries having their own config and reading those. The base assumption is that the config comes from the host app - either a Myapp.exe.config for a WPF, Winforms or console app, or the web.config for a web app.

There are ways to grab config information from custom config files - but again: those are not the standard, supported .NET configuration scenarios, so you'll have to do a lot of work yourself and you might run into issues.

To see how this would work, check out You should also check out Cracking the mysteries of .NET 2.0 configuration written by Jon Rista - excellent material.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜