473,787 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cant read app.config

I added an app.config file to my application. (c#.net component dll)

<?xml version="1.0" encoding="utf-8"?>
<configuratio n>

<appSettings>
<add key="username" value="xx" />
<add key="password" value="xx" />
</appSettings>
</configuration>

I then try to read it in my code as:

_username = ConfigurationSe ttings.AppSetti ngs["username"].ToString();

The only using reference i have is using System; and
System.Configur ation;

I get an error when trying to read it saying the value is null.
(running my application in debug mode. This component is being called
by an ASP.NET application also running in debug under the same
session)

What am i doing wrong here? Iv read a lot of forums and searched all
over google but ims till very confused.

Should i do anything with the app.config file? Do i have to name it
something else or move it into the bin folders?

Any help would be appreciated.
Jul 21 '05 #1
2 3316
DLLs to not use the config files. So, make sure the config file for the
appliction (.EXE) has the necessary config settings.
"MrFile" <we********@yah oo.com> wrote in message
news:9a******** *************** *@posting.googl e.com...
I added an app.config file to my application. (c#.net component dll)

<?xml version="1.0" encoding="utf-8"?>
<configuratio n>

<appSettings>
<add key="username" value="xx" />
<add key="password" value="xx" />
</appSettings>
</configuration>

I then try to read it in my code as:

_username = ConfigurationSe ttings.AppSetti ngs["username"].ToString();

The only using reference i have is using System; and
System.Configur ation;

I get an error when trying to read it saying the value is null.
(running my application in debug mode. This component is being called
by an ASP.NET application also running in debug under the same
session)

What am i doing wrong here? Iv read a lot of forums and searched all
over google but ims till very confused.

Should i do anything with the app.config file? Do i have to name it
something else or move it into the bin folders?

Any help would be appreciated.

Jul 21 '05 #2
According to your post, you are dealing with ASP.NET.
Therefore, you need to place an <appSettings> section in your Web.Config
file.

By the way, if you really need to dedicate an config file to a dll (and not
using the .exe.config), you will need to load the dll in a separate
AppDomain and provide the config file before loading the appDomain.

José
"MrFile" <we********@yah oo.com> wrote in message
news:9a******** *************** *@posting.googl e.com...
I added an app.config file to my application. (c#.net component dll)

<?xml version="1.0" encoding="utf-8"?>
<configuratio n>

<appSettings>
<add key="username" value="xx" />
<add key="password" value="xx" />
</appSettings>
</configuration>

I then try to read it in my code as:

_username = ConfigurationSe ttings.AppSetti ngs["username"].ToString();

The only using reference i have is using System; and
System.Configur ation;

I get an error when trying to read it saying the value is null.
(running my application in debug mode. This component is being called
by an ASP.NET application also running in debug under the same
session)

What am i doing wrong here? Iv read a lot of forums and searched all
over google but ims till very confused.

Should i do anything with the app.config file? Do i have to name it
something else or move it into the bin folders?

Any help would be appreciated.

Jul 21 '05 #3

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

Similar topics

4
2844
by: Duncan | last post by:
Hi I'm doing a site that creates a cookie and then needs to read that cookie later. The cookie is created fin and I can see it in my browsers cookies but I can't seem to read it. I've tried referring to the variable straight as $cookie_var and as $_COOKIE but no luck. if I var_dump($_COOKIE) I get array(0) { }
3
2619
by: Mustaq | last post by:
Hi, How to read same config file from different application? I have 4 application in VB.NET, all are using different app.config files. NOW I need all to read only one config file, how can I do this. Thanks in Adv. Regards,
1
5361
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; Anybody able to give me idea how-to read by C# element which I add to the machine.config into the new single section?
0
1724
by: Tony Lewis | last post by:
I'm running IIS on a Windows 2k server and have just installed the .NET framework 1.1 so I can deploy ASP.NET applications on my server through .NET Studios. All my normal ASP applications run fine in IIS but I can't run any ASP.NET pages. Everything in IIS was configured to handle the .aspx file extension by the .NET framework installation and it installed with no errors. When I try to view a simple ASP.NET page through a web browser I...
0
934
by: Mark Shehan | last post by:
I am using VS2005 and ASP.NET 2 I want to use IIS to host some .NET remoting. I have a website I created called RemotingHost. I created another class project called RemotingServer and in there a class called TestClass (inherits Marshallbyrefobject for remoting). I then added the built assembly to the bin folder on the RemotingHost website. I created a web config file with system.runtime.remoting wellknown service for the testclass as...
2
282
by: MrFile | last post by:
I added an app.config file to my application. (c#.net component dll) <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="username" value="xx" /> <add key="password" value="xx" /> </appSettings> </configuration>
5
2296
by: Sridhar | last post by:
Hi, I have created a project which contains classes to read the data from the database. This project has an App.Config file which contains the SqlConnection String. when this code is called from a web application and if I need to read the connection string it is reading the connection string from the web.config of web application. I am not knowing how to change the Application domain so that it reads the App.config file instead of...
2
1345
by: VB Programmer | last post by:
I used to be able to change minor settings in my web.config file when it was on the web server, such as <appSettings> elements. In ASP.NET 2.0 I noticed that there is a web.config AND a PrecompiledApp.config file. So, how can I change <appSettings> (or other) elements once it's been deployed to the server? Thanks!
6
2479
by: WolfgangS | last post by:
Ok first off, i am a total beginner at this groups stuff and i have no clue how this works. This is probabaly the wrong group for my problem but i will post it anyways. Learning by doing right? I will post a code snippet and explain my problem. I cant seem to find a logical explanation why this problem would occur after trying to figure it out for a few hours. However I am probably just blind and/or stupid and you will realise where i go...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.