How to read app.config from a dll

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

as long as the dll and main exe in the same folder, the dll shud be able to
pick the conf up.

regards
 
Hi,

I don't really remember if you can get it using
ConfigurationSettings.AppSettings 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,
 
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
 
Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

I don't really remember if you can get it using
ConfigurationSettings.AppSettings 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.
 
Hi,

I think the same, if the dlls are in the same appdomain then they should
"see" the ConfigurationSettings.AppSettings cause it's static and visible in
the appdomain.


cheers,
 
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.Configuration" to your using clause

and
2) Specifying
string myItem =
ConfigurationSettings.AppSettings["MyConfigItem"]

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

Marc
 
If it is in a different section of the Configuration file, the
ConfigurationSettings class and the System.Configuration 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.
 
Back
Top