DLL读取配置文件 [英] dll read config file
问题描述
我正在创建一个将由asp.net
应用程序使用的C#类文件(DLL)。在DLL中我想读取web.config或app.config文件,所以
一些信息可以改变,而不必进入代码本身。怎么
我可以让dll读取app.config或web.config文件中的数据吗?
我想要存储的信息文件是服务器名,文件
位置等
谢谢
签出< ; appSetings>和System.Configuration.ConfigurationSettings
类为v1.x.除此之外,没有好的方法来阅读配置文件
(手动XML解析除外)。在v2.0中有一个适当的API,可以通过System.Configuration.ConfigurationManager读取设置。
-Brock
DevelopMentor
http://staff.develop.com/ballen
我正在创建一个将由asp.net
应用程序使用的C#类文件(DLL)。在DLL中我想读取web.config或app.config
文件,这样一些信息可以更改而无需进入代码本身。如何让dll读取app.config或web.config文件来获取数据?
我想要存储在文件中的信息是servernames,file
位置等
感谢
我知道appSettings可以在asp.net应用程序中运行但是dll怎么样
不包含在asp.net项目中?
" Brock Allen" < BA **** @ NOSPAMdevelop.com>在消息中写道
news:b8 ************************** @ msnews.microsoft .com ... < blockquote class =post_quotes>签出< appSetings>和v1.x的System.Configuration.ConfigurationSettings
类。除此之外,没有好的方法来阅读配置文件(除了手动XML解析)。在v2.0中,有一个适当的API可以通过System.Configuration.ConfigurationManager读取设置。
-Brock
DevelopMentor
http://staff.develop.com/ballen
I ''正在创建一个将由asp.net
应用程序使用的C#类文件(DLL)。在DLL中我想读取web.config或app.config
文件,这样一些信息可以更改而无需进入代码本身。如何让dll读取app.config或web.config文件来获取数据?
我想要存储在文件中的信息是servernames,file
地点等
感谢
" NuB" < CS ********* @ optonline.net>写在
新闻:大江************** @ TK2MSFTNGP11.phx.gbl:
我是创建一个将由asp.net
应用程序使用的C#类文件(DLL)。在DLL中我想读取web.config或app.config
文件,这样一些信息可以更改而无需进入代码本身。如何让dll读取app.config或web.config文件来获取数据?
使用标准方法访问配置文件: br />
System.Configuration.ConfigurationSettings.AppSett ings.Item(" MyKey")
在ASP.NET项目中实例化DLL时,它将访问
web.config。
当您在VB.NET项目中实例化DLL时,它将访问
app.config。
-
Lucas Tam(RE********@rogers.com)
请删除删除来自回复时的电子邮件地址。
Newmarket沃尔沃糟透了! http://newmarketvolvo.tripod.com
>
I''m creating a C# class file(DLL) that will be used by an asp.net
application. In the DLL I want to read a web.config, or app.config file so
some information can change without having to go into the code itself. How
can I have the dll read a app.config or web.config file for data?
The information I''m looking to store in the file is servernames, file
locations, etc.
thanks
Check out <appSetings> and the System.Configuration.ConfigurationSettings
class for v1.x. Other than that, there''s no good way to read the config file
(other than manual XML parsing). In v2.0 there''s a proper API for reading
the settings via System.Configuration.ConfigurationManager.
-Brock
DevelopMentor
http://staff.develop.com/ballen
I''m creating a C# class file(DLL) that will be used by an asp.net
application. In the DLL I want to read a web.config, or app.config
file so some information can change without having to go into the code
itself. How can I have the dll read a app.config or web.config file
for data?
The information I''m looking to store in the file is servernames, file
locations, etc.
thanks
I know appSettings will work from a asp.net app but what about a dll that is
not included in the asp.net project?
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...Check out <appSetings> and the System.Configuration.ConfigurationSettings
class for v1.x. Other than that, there''s no good way to read the config
file (other than manual XML parsing). In v2.0 there''s a proper API for
reading the settings via System.Configuration.ConfigurationManager.
-Brock
DevelopMentor
http://staff.develop.com/ballenI''m creating a C# class file(DLL) that will be used by an asp.net
application. In the DLL I want to read a web.config, or app.config
file so some information can change without having to go into the code
itself. How can I have the dll read a app.config or web.config file
for data?
The information I''m looking to store in the file is servernames, file
locations, etc.
thanks
"NuB" <cs*********@optonline.net> wrote in
news:Oe**************@TK2MSFTNGP11.phx.gbl:
I''m creating a C# class file(DLL) that will be used by an asp.net
application. In the DLL I want to read a web.config, or app.config
file so some information can change without having to go into the code
itself. How can I have the dll read a app.config or web.config file
for data?
Use the standard methods for accessing the configuration file:
System.Configuration.ConfigurationSettings.AppSett ings.Item("MyKey")
When you instantiate your DLL in a ASP.NET project, it will have access the
the web.config.
When you instantiate your DLL in a VB.NET project, it will have access the
the app.config.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
这篇关于DLL读取配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!