471,354 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

dll read config file

NuB
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
Nov 19 '05 #1
10 2399
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

Nov 19 '05 #2
NuB
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/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


Nov 19 '05 #3
"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
Nov 19 '05 #4
NuB
i want a seperate config file for the dll, in case the dll is going to used
by another type of project such as a windows app. Right now its being
designed for a asp.net web app, but that could change in the future.

Could I create an XML file and read the tags in that for my information, and
if so how would i do that?

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@127.0.0.1...
"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

Nov 19 '05 #5
"NuB" <cs*********@optonline.net> wrote in
news:ez**************@TK2MSFTNGP11.phx.gbl:
i want a seperate config file for the dll, in case the dll is going to
used by another type of project such as a windows app. Right now its
being designed for a asp.net web app, but that could change in the
future.

Could I create an XML file and read the tags in that for my
information, and if so how would i do that?


No need to create a separate config file - the way you read the config file
is the same for both ASP.NET and VB.NET projects. The DLL will work in both
ASP.NET and VB.NET projects (as long as you use the System.Configuration
classes.

The DLL will switch "files" depending on the context it is loaded (i.e.
ASP.NET or VB.NET).

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #6
NuB
So in my web.config file for the asp.net web app I'm creating, if I have a
key named server and the actual asp.net file does not use that key I can
read it from the DLL I'm creating?


"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@127.0.0.1...
"NuB" <cs*********@optonline.net> wrote in
news:ez**************@TK2MSFTNGP11.phx.gbl:
i want a seperate config file for the dll, in case the dll is going to
used by another type of project such as a windows app. Right now its
being designed for a asp.net web app, but that could change in the
future.

Could I create an XML file and read the tags in that for my
information, and if so how would i do that?


No need to create a separate config file - the way you read the config
file
is the same for both ASP.NET and VB.NET projects. The DLL will work in
both
ASP.NET and VB.NET projects (as long as you use the System.Configuration
classes.

The DLL will switch "files" depending on the context it is loaded (i.e.
ASP.NET or VB.NET).

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com

Nov 19 '05 #7
NuB
also to note: this is a separate project DLL (class). I did not add a class
to an existing asp.net web application. I created a seperate project which
is just this DLL file I want to use
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@127.0.0.1...
"NuB" <cs*********@optonline.net> wrote in
news:ez**************@TK2MSFTNGP11.phx.gbl:
i want a seperate config file for the dll, in case the dll is going to
used by another type of project such as a windows app. Right now its
being designed for a asp.net web app, but that could change in the
future.

Could I create an XML file and read the tags in that for my
information, and if so how would i do that?


No need to create a separate config file - the way you read the config
file
is the same for both ASP.NET and VB.NET projects. The DLL will work in
both
ASP.NET and VB.NET projects (as long as you use the System.Configuration
classes.

The DLL will switch "files" depending on the context it is loaded (i.e.
ASP.NET or VB.NET).

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com

Nov 19 '05 #8
"NuB" <cs*********@optonline.net> wrote in
news:#A**************@TK2MSFTNGP14.phx.gbl:
So in my web.config file for the asp.net web app I'm creating, if I
have a key named server and the actual asp.net file does not use that
key I can read it from the DLL I'm creating?

I believe your DLL will read keys from the web.config.

Not sure if you can have a DLL config AND a Web.config.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #9
An assembly can access the application's config file. What do you mean by
"not included in the asp.net project"?

-Brock
DevelopMentor
http://staff.develop.com/ballen
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/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

Nov 19 '05 #10
NuB
its a seperate project. I created a new project which is the dll I'm
creating. This dll can be used by either an asp.net project or a windows
application.

I didn't add a Class to an existing asp.net project, it is own project
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
An assembly can access the application's config file. What do you mean by
"not included in the asp.net project"?

-Brock
DevelopMentor
http://staff.develop.com/ballen
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/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


Nov 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by MrFile | last post: by
1 post views Thread by vkrasner | last post: by
5 posts views Thread by Dica | last post: by
4 posts views Thread by Chris V | last post: by
4 posts views Thread by Steve Enzer | last post: by
3 posts views Thread by Brett Romero | last post: by
1 post views Thread by Todd Brewer | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.