473,799 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read app.config from a dll

I have the main project that where is my app.config. I have a project dll
called Data, that must to read from the app.config that belongs the main
project a string connection. When i debug thats returns null. How can i read
my connection string. I´d like a sample or a link that i could download it.
Thanks
Nov 17 '05 #1
6 3056
as long as the dll and main exe in the same folder, the dll shud be able to
pick the conf up.

regards
Nov 17 '05 #2
Hi,

I don't really remember if you can get it using
ConfigurationSe ttings.AppSetti ngs from the dll, I assume you tried this
right?

The other option you have is store this info in a static member of your
connection class from the Data dll.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Daniel Caetano" <ne**@microsoft .com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I have the main project that where is my app.config. I have a project dll
called Data, that must to read from the app.config that belongs the main
project a string connection. When i debug thats returns null. How can i
read
my connection string. I´d like a sample or a link that i could download
it.
Thanks

Nov 17 '05 #3
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

I don't really remember if you can get it using
ConfigurationSe ttings.AppSetti ngs from the dll, I assume you tried this
right?


In fact, in a prj that im workin on. the main exe just a 'kick start' single
file with a bunch of resources. ALL functions have been built by DLLs
(roughly 8 prj DLLs). I hav never seen prob like this.
Nov 17 '05 #4
Hi,

I think the same, if the dlls are in the same appdomain then they should
"see" the ConfigurationSe ttings.AppSetti ngs cause it's static and visible in
the appdomain.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ashura" <As****@discuss ions.microsoft. com> wrote in message
news:8F******** *************** ***********@mic rosoft.com...
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

I don't really remember if you can get it using
ConfigurationSe ttings.AppSetti ngs from the dll, I assume you tried this
right?


In fact, in a prj that im workin on. the main exe just a 'kick start'
single
file with a bunch of resources. ALL functions have been built by DLLs
(roughly 8 prj DLLs). I hav never seen prob like this.

Nov 17 '05 #5
>I have the main project that where is my app.config. I have a project dll
called Data, that must to read from the app.config that belongs the main
project a string connection. When i debug thats returns null. How can i read
my connection string. I´d like a sample or a link that i could download it.


You should be able to get at any entry in the
<configuration> <appSettings> section from your DLL by

1) adding a "using System.Configur ation" to your using clause

and
2) Specifying
string myItem =
ConfigurationSe ttings.AppSetti ngs["MyConfigIt em"]

Can you SHOW us the app.config of the main app, and the relevant code
lines in your DLL?

Marc
Nov 17 '05 #6
If it is in a different section of the Configuration file, the
ConfigurationSe ttings class and the System.Configur ation namespace have lots
of methods for reading Configuration settings.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi,

I don't really remember if you can get it using
ConfigurationSe ttings.AppSetti ngs from the dll, I assume you tried this
right?

The other option you have is store this info in a static member of your
connection class from the Data dll.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Daniel Caetano" <ne**@microsoft .com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I have the main project that where is my app.config. I have a project dll
called Data, that must to read from the app.config that belongs the main
project a string connection. When i debug thats returns null. How can i
read
my connection string. I´d like a sample or a link that i could download
it.
Thanks


Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2391
by: Karthikesh Raju | last post by:
Hi All, i am wondering about the best way to read in a configuration file that goes like: ########### source_dir = '/home/karthik/Projects/python' data_dir = '/home/karthik/Projects/data'
2
3317
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 key="password" value="xx" /> </appSettings> </configuration>
3
2619
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 this. Thanks in Adv. Regards,
1
5362
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; Anybody able to give me idea how-to read by C# element which I add to the machine.config into the new single section?
4
3001
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 set to an instance of an object." message I thought this may have been to do with Virtual Directory settings but I've got the folder set as an application in IIS and asp.net is installed and working. My web.config file is Not Marked read-only and...
4
1809
by: brent | last post by:
Currently our application is reading from the web.config, and retrieves a section, "softwareRequirements". Because the section will begin to grow dramatically, I'd like to place it in the SQL database instead. I've imported the values, and am retrieving them as FOR XML AUTO in the stored proc to mimic the structure in the web.config. I'm confused now - what data type is being returned by...
10
2556
by: NuB | last post by:
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
5
2296
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 a web application and if I need to read the connection string it is reading the connection string from the web.config of web application. I am not knowing how to change the Application domain so that it reads the App.config file instead of...
3
15967
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 content: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections>
9
4275
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to read the value of redirect from the error statusCode 404. My web.config looks like this: <customErrors mode="RemoteOnly" defaultRedirect="Error.aspx"> <error statusCode="404" redirect="Error404.aspx" /> </customErrors>
0
9543
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10029
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.