config file for Class Library?

  • Thread starter Thread starter Hayato Iriumi
  • Start date Start date
H

Hayato Iriumi

Say, you have a C# project called "MyClassLib". So the project would
generate MyClassLib.dll. I want MyClassLib.dll to get some setting
information, so I thought of creating MyClassLib.dll.config. This obviously
doesn't work cuz it doesn't seem to be supported. Alternative solution would
be to create your own XML file and a class that reads it... What I'm
wondering is if there is any way that's supported by .NET framework....

TIA
 
Hayato,

It is not currently supported in the framework. You can try and access
the information in the .config file for the application (through the current
mechanism), or you can code your own mechanism. Using XML serialization, or
the SOAP formatter to serialize an object which has the properties you need
to access would probably be the easiest way to do this.

Hope this helps.
 
Hi,

The dll will always take configuration setting
information of the surrogate i.e.,

If MyClassLib.dll is used by MyProject.exe then
MyClassLib.dll will read the configuration setting from
MyProject.exe.config.

If you have deployed your component MyClassLib.dll in
COM+ then it reads config settings from
dllhost.exe.config since dllhost.exe is the surrogate.

Hope this helps...

Regards,
Madhu

MVP | MCSD.NET
-----Original Message-----
Say, you have a C# project called "MyClassLib". So the project would
generate MyClassLib.dll. I want MyClassLib.dll to get some setting
information, so I thought of creating
MyClassLib.dll.config. This obviously
 
Hi, Madhu.
Yeah, that's what I just found out. I was able to get the config values from
the MyExe.exe.config. I guess this is because the DLL runs within
MyExe.exe's AppDomain.

Thanks!
 
Back
Top