Retrieving DSN from Config file...

C

Charlie

Hi:

I created a config file to retrieve DSN at runtime from a C# library project
(DLL). I name the file same as DLL (libRADIUS.config). Here is the
contents of the file...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="dsn" value="server=arwen;uid=;pwd=;database=dbRadius" />
</appSettings>
</configuration>

I'm accessing from a class using...

string dsn = ConfigurationSettings.AppSettings["dsn"];

The problem is that it always returns null. Does anybody know why?

Thanks,
Charlie
 
C

Charlie

Interesting. Then how do you store application configuration settings that
you want to be able to change without recompiling DLL?

Charlie
Peter Rilling said:
You cannot map a config file to a DLL, only an EXE or website.

Charlie said:
Hi:

I created a config file to retrieve DSN at runtime from a C# library project
(DLL). I name the file same as DLL (libRADIUS.config). Here is the
contents of the file...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="dsn" value="server=arwen;uid=;pwd=;database=dbRadius" />
</appSettings>
</configuration>

I'm accessing from a class using...

string dsn = ConfigurationSettings.AppSettings["dsn"];

The problem is that it always returns null. Does anybody know why?

Thanks,
Charlie
 
P

Peter Rilling

Place the exact name/value setting that you have below in your app.config
for the application.

If there is no application, such as if this is a generic library, then this
will have to be part of the installation or instructions to the user to
ensure this gets added to the app.config.

DLLs can use configuration settings, but they come from the app.config file.

Charlie said:
Interesting. Then how do you store application configuration settings that
you want to be able to change without recompiling DLL?

Charlie
Peter Rilling said:
You cannot map a config file to a DLL, only an EXE or website.

Charlie said:
Hi:

I created a config file to retrieve DSN at runtime from a C# library project
(DLL). I name the file same as DLL (libRADIUS.config). Here is the
contents of the file...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="dsn" value="server=arwen;uid=;pwd=;database=dbRadius" />
</appSettings>
</configuration>

I'm accessing from a class using...

string dsn = ConfigurationSettings.AppSettings["dsn"];

The problem is that it always returns null. Does anybody know why?

Thanks,
Charlie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top