473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ConfigurationSettings.AppSettings

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.
Jun 7 '06 #1
5 12500
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

Jun 7 '06 #2
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.

"Michael Nemtsev" <ne*****@msn.com> wrote in message
news:02**********************************@microsof t.com...
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

Jun 7 '06 #3
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.

"Michael Nemtsev" <ne*****@msn.com> wrote in message
news:02**********************************@microsof t.com...
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

Jun 7 '06 #4
You can use
if (System.Web.HttpContext.Current ==null)

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simon Hart" wrote:
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.

"Michael Nemtsev" <ne*****@msn.com> wrote in message
news:02**********************************@microsof t.com...
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


Jun 7 '06 #5
Excellent tip, thanks.

Regards
Simon.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:AD**********************************@microsof t.com...
You can use
if (System.Web.HttpContext.Current ==null)

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simon Hart" wrote:
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.

"Michael Nemtsev" <ne*****@msn.com> wrote in message
news:02**********************************@microsof t.com...
> 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
>


Jun 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Filippo | last post by:
Hi there, I am writing a Windows App and need a Configuration file. I wonder if I can use the WEB.CONFIG file to store my values. I also wonder if I can use the ConfigurationSettings.AppSettings...
5
by: Derrick | last post by:
I have a C# console app, MyApp, and am placing an application config file in the same debug dir as MyApp.exe. I have named the file MyApp.config, and MyApp.exe.config. I cannot read the...
2
by: Dean Slindee | last post by:
What is the VS2005 version of ConfigurationSettings.AppSettings: Dim strTemp As String strTemp = ConfigurationSettings.AppSettings.Get(Application.ProductName & "/" & strKeyID)
4
by: RSH | last post by:
Hi, I have a situation where I am attempting to print the contents of an AppSettings property in the aspx file of my website. Basically here is the code I am using: <% Response.Write("Email:"...
1
by: Jenny | last post by:
Hello, I read my applications App.Config file using ConfigurationSettings.AppSettings When I try to check it's last access write time using File.GetLastWriteTime and the refresh new data...
8
by: Mark | last post by:
Could someone provide me with details or a link on how the line of code executes underneath the hood? Assume it's executed in an ASP.NET application. string blah =...
3
by: John | last post by:
Hi If I use ConfigurationSettings.AppSettings.Set("KeyName", "KeyValue"), where does the KeyName/KeyValue combination ends up? In a file? In windows registry? Thanks Regards
1
by: Ken | last post by:
I'm currently using 1.1. Is there any way using the value of a ConfigurationSettings.AppSettings as a key of ConfigurationSettings.AppSettings.Tosting( )]? for example in web.config <add...
2
by: mark4asp | last post by:
In trying to get the C# conversion code for Head First Design Patterns to work I came accross a number of warnings. e.g. Warning Number: 10 Description: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.