ConfigurationSettings.AppSettings

S

Simon Hart

Hi,

I want to use the ConfigurationSettings.AppSettings from within a .NET class
library that gets called. If using the above class, what would the name of
the config file be? would this be the name of the DLL that is calling it as
per a Windows EXE ie : myexe.exe.config.
I have named my Xml file mydll.dll.config where mydll is the name of my
class library, but it doesn't seem to work.

The config file is correct ie:

<configuration>
<appSettings>
<add key="IP" value="Myip"/>
</appSettings>
</configuration>

I have never had a problem with using ConfigurationSettings in for example
ASP.NET and normal WinForm executables, but have never had a requirement up
until now.
To clear up any confusion, the class library gets called from MS CRM 3.0.

Regards
Simon.
 
G

Guest

Class libaries can't have configs, and you can't use AppSettings it this case
Use System.Xml namespace and treat config as XML file manually
I want to use the ConfigurationSettings.AppSettings from within a .NET class
library that gets called. If using the above class, what would the name of
the config file be? would this be the name of the DLL that is calling it as
per a Windows EXE ie : myexe.exe.config.
I have named my Xml file mydll.dll.config where mydll is the name of my
class library, but it doesn't seem to work.

The config file is correct ie:

<configuration>
<appSettings>
<add key="IP" value="Myip"/>
</appSettings>
</configuration>

I have never had a problem with using ConfigurationSettings in for example
ASP.NET and normal WinForm executables, but have never had a requirement up
until now.
To clear up any confusion, the class library gets called from MS CRM 3.0.

Regards
Simon.

--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
S

Simon Hart

Thanks for your reply.

I thought this might be the case. The problem is I am reusing a generic
class that gets used from an ASP.NET Web Service where there is a web.config
file to store IP addresses etc. I wanted to reuse this class in my class
library without changing any logic in the class library.
I guess I will have to detect someway of whether I am running under a Web
Service or not.

Simon.
 
G

Guest

Use Process process = Process.GetCurrentProcess();
process.ProcessName return the name of your process

For the webService it will be "WebDev.WebServer" string (VS 2005)
I thought this might be the case. The problem is I am reusing a generic
class that gets used from an ASP.NET Web Service where there is a web.config
file to store IP addresses etc. I wanted to reuse this class in my class
library without changing any logic in the class library.
I guess I will have to detect someway of whether I am running under a Web
Service or not.

Simon.

--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 

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