473,386 Members | 1,673 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,386 software developers and data experts.

Cant read app.config

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>

I then try to read it in my code as:

_username = ConfigurationSettings.AppSettings["username"].ToString();

The only using reference i have is using System; and
System.Configuration;

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 3275
DLLs to not use the config files. So, make sure the config file for the
appliction (.EXE) has the necessary config settings.
"MrFile" <we********@yahoo.com> wrote in message
news:9a************************@posting.google.com ...
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>

I then try to read it in my code as:

_username = ConfigurationSettings.AppSettings["username"].ToString();

The only using reference i have is using System; and
System.Configuration;

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********@yahoo.com> wrote in message
news:9a************************@posting.google.com ...
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>

I then try to read it in my code as:

_username = ConfigurationSettings.AppSettings["username"].ToString();

The only using reference i have is using System; and
System.Configuration;

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
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...
3
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...
1
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; ...
0
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...
0
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...
2
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...
5
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...
2
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...
6
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? ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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,...

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.