473,503 Members | 6,587 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2520
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3285
by: MrFile | last post by:
I added an app.config file to my application. (c#.net component dll) <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="username" value="xx" /> <add...
3
2574
by: Mustaq | last post by:
Hi, How to read same config file from different application? I have 4 application in VB.NET, all are using different app.config files. NOW I need all to read only one config file, how can I do...
1
5311
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; ...
5
2328
by: Dica | last post by:
i've followed the instructions i found here about how to add a config file to my applicaiton: http://www.c-sharpcorner.com/Code/2003/Nov/CreateUseConfigFiles.asp the instructions state that i...
4
2983
by: Chris V | last post by:
I'm having a problem deploying my ASP.NET application to a WIN2k server. (IIS5 .NET 1.1) When I try to access ConfigurationSettings.AppSettings("WhateverValue") I get an "Object reference not...
4
1871
by: Steve Enzer | last post by:
I need to use a configuration file to set the connection string for the ado data connector in my project, but I'm having trouble reading the config file. My config file contains the following: ...
5
2271
by: Sridhar | last post by:
Hi, I have created a project which contains classes to read the data from the database. This project has an App.Config file which contains the SqlConnection String. when this code is called from...
3
15952
by: Brett Romero | last post by:
I'd like to use some of the techniques discussed here for reading a config file in .NET 2.0: http://msdn.microsoft.com/msdnmag/issues/06/06/ConfigureThis/default.aspx Here's my app.config...
1
4158
by: Todd Brewer | last post by:
I have an ASP.NET web site that uses a .NET dll. The DLL has a DataSet in it. Problem is, the DLL uses an app.config file (and worse yet, it uses the stupid settings.settings file, which in turn...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
371
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.