Retrieving DSN from Config file...

  • Thread starter Thread starter Charlie
  • Start date Start date
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
 
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
 
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
 
Back
Top