473,229 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,229 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 2501
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
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
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
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
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
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
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
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
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
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
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.