473,466 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can't get value from app.config

I have a simple C# VS 2005 console application that contains a class and an
app.config file.

My app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key = "KW_Geometry_CheckIn_Path" value="\\kwcyarm006
Batchplot\Input\Iput" />
<add key = "KW_Geometry_CheckOut_Path" value="yes" />
<add key = "PB_Geometry_CheckIn_Path"
value="\\PBCDEPM216\PBCDEP-Batchplot\input\IPut" />
<add key = "PB_Geometry_CheckOut_Path" value="yes" />
</appSettings>
</configuration>
I have included the reference to
using System.Configuration;
using System.Collections.Specialized;
using System.Collections.ObjectModel;
using System.Data;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
My app code is:

string configpath =
ConfigurationManager.AppSettings.Get("KW_Geometry_ CheckIn_Path");

This will compile but won't read the value and shows a null string. I tried
using the ConfigurationSettings.AppSettings but get a deprecated error. Can
someone help with the proper syntax to retrieve the value from the app.config?

Thanks
--
Tastes like burning
Nov 9 '07 #1
1 4586
Try using :

ConfigurationManager.AppSettings["KW_Geometry_CheckIn_Path"];

--
Ged Moretta
www.appsense.com

-----------------------------------------------------------------------
This signature isn't automatic. I have to type it manually every time.
"spurvia" <sp*****@discussions.microsoft.comwrote in message
news:D2**********************************@microsof t.com...
>I have a simple C# VS 2005 console application that contains a class and an
app.config file.

My app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key = "KW_Geometry_CheckIn_Path" value="\\kwcyarm006
Batchplot\Input\Iput" />
<add key = "KW_Geometry_CheckOut_Path" value="yes" />
<add key = "PB_Geometry_CheckIn_Path"
value="\\PBCDEPM216\PBCDEP-Batchplot\input\IPut" />
<add key = "PB_Geometry_CheckOut_Path" value="yes" />
</appSettings>
</configuration>
I have included the reference to
using System.Configuration;
using System.Collections.Specialized;
using System.Collections.ObjectModel;
using System.Data;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
My app code is:

string configpath =
ConfigurationManager.AppSettings.Get("KW_Geometry_ CheckIn_Path");

This will compile but won't read the value and shows a null string. I
tried
using the ConfigurationSettings.AppSettings but get a deprecated error.
Can
someone help with the proper syntax to retrieve the value from the
app.config?

Thanks
--
Tastes like burning
Nov 9 '07 #2

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

Similar topics

2
by: Jared Hagel | last post by:
I've searched the web for a solution to this problem. Surprisingly, no problem/solution has been posted yet. We can read application configuration information fine when our asp.net application...
6
by: Rich | last post by:
Hello, I picked up this example on using the Reflection namespace for loading forms/classes on the fly at msdn http://msdn.microsoft.com/library/default.asp?...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
5
by: Alberto | last post by:
I need to modify a value in the app.config file with this code: System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string key =...
2
by: mahesh.anjani | last post by:
hi i have stored my connction string in web.config as we do usually. code of web.confing is given below. check the password field contain "&" character. now when i run my application it gives...
10
by: Brett Romero | last post by:
I'd like to store something such as the following the my app.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="DEBUG" value="true"/> <add...
2
by: forest demon | last post by:
I need to be able to create an appender to direct output to a MessageBox. The API does not have a MessageBox appender like nLog does. What would be the easiest way to do this. The examples...
3
by: Mark Rae | last post by:
Hi, Apologies if this is a stupid question, but it's late... I have a C# 2 WinForms project called RTES, and I'm trying to add new key/value pairs to the appSettings section of its config...
2
by: remya1000 | last post by:
i'm using VB.NET 2003. Last time while i did a program in Vb.Net 2005, i use "Configuration". and i could read and write to that XML configuration file like the example below. CODES:...
8
lifeisgreat20009
by: lifeisgreat20009 | last post by:
What might be the possible cause ? I have created a website using struts framework, jsp In my transaction page the money is not getting transferred.. When I hit the submit button in my...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...
0
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 ...

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.