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

How to retrieve appsetings in WinForm Application?

ad
I have define some appsetings in ap.config like:

<configuration>
<appSettings>
<add key="MailBody" value="Test Mail body"/>
</appSettings>

.....

I use
txtSubject.Text =
ConfigurationManager.AppSettings["MailSubject"].ToString();

But it can't compile.

How can I retrieve appsetings in WinForm applicaiton
Nov 17 '05 #1
5 18934
Hi,

you should use

System.Configuration.ConfigurationSettings.AppSett ings["MailBody"];

You should better read the value into a string first
and after you check that it isn't null set it where
you need it.

Cheers
Lars Behrmann

_________________
Nothing is impossible. UML is the key for all your problems.
AODL - Make your .net apps OpenOffice ready
http://aodl.sourceforge.net/
ad schrieb:
I have define some appsetings in ap.config like:

<configuration>
<appSettings>
<add key="MailBody" value="Test Mail body"/>
</appSettings>

....

I use
txtSubject.Text =
ConfigurationManager.AppSettings["MailSubject"].ToString();

But it can't compile.

How can I retrieve appsetings in WinForm applicaiton


Nov 17 '05 #2
ad <fl****@wfes.tcc.edu.tw> wrote:
I have define some appsetings in ap.config like:

<configuration>
<appSettings>
<add key="MailBody" value="Test Mail body"/>
</appSettings>

....

I use
txtSubject.Text =
ConfigurationManager.AppSettings["MailSubject"].ToString();

But it can't compile.

How can I retrieve appsetings in WinForm applicaiton


It should be ConfigurationSettings.AppSettings, not
ConfigurationManager.AppSettings.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #3
ad
I am using VS2005, it say that the ConfigurationSettings is obsoleted.

"Jon Skeet [C# MVP]" <sk***@pobox.com>
???????:MP************************@msnews.microsof t.com...
ad <fl****@wfes.tcc.edu.tw> wrote:
I have define some appsetings in ap.config like:

<configuration>
<appSettings>
<add key="MailBody" value="Test Mail body"/>
</appSettings>

....

I use
txtSubject.Text =
ConfigurationManager.AppSettings["MailSubject"].ToString();

But it can't compile.

How can I retrieve appsetings in WinForm applicaiton


It should be ConfigurationSettings.AppSettings, not
ConfigurationManager.AppSettings.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 17 '05 #4
Hello ad,
I have define some appsetings in ap.config like:
<configuration> <appSettings> <add key="MailBody"
value="Test Mail body"/> </appSettings> </configuration>
I use: txtSubject.Text =
ConfigurationManager.AppSettings["MailSubject"].ToString();
But it can't compile.
How can I retrieve appsetings in WinForm applicaiton


Thats ok, if you use .NET Framework 2.0, so

// insert reference to system.configuration.dll [2.0]
// using System.Configuration.
string s = ConfigurationManager.AppSettings["MailBody"];
ciao Frank
--
Dipl.Inf. Frank Dzaebel [MCP/MVP C#]
http://Dzaebel.NET
Nov 17 '05 #5
ad <fl****@wfes.tcc.edu.tw> wrote:
I am using VS2005, it say that the ConfigurationSettings is obsoleted.


Ah. It would have helped if you'd said that to start with...

ConfigurationManager should be fine then. Here's a sample program that
works:

using System;
using System.Configuration;

public class Test
{
static void Main()
{
Console.WriteLine (ConfigurationManager.AppSettings["Foo"]);
}
}

Test.exe.config:
<?xml version="1.0" ?>
<configuration>
<appSettings>
<add key="Foo" value="Bar" />
</appSettings>
</configuration>

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #6

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

Similar topics

0
by: charbonneau | last post by:
I need to develop a WinForm application which can play .mp3 music files stored on another machine on a LAN. This applicaiton needs to run on servaral different client machines at the same time. I...
1
by: Pramod Thewarkar | last post by:
Hi, I have deployed my winform application on iis server in a virtual directory. On the start of my application, it is reading some information from the config file (app.config). When i am...
9
by: Dayne | last post by:
I need to have a auto timeout feature for a webform application(vb.net). Basically, I want to close the application if the user does not have a keyboard or mouse input after a specific period of...
0
by: Cenray | last post by:
How to generate a web request from a Winform Application using a WebService? In a C# Windows Application, when I try to genrate a web request using the following code, it is woking fine ...
1
by: Ollie Riches | last post by:
Does anyone know a way to create a winform window that has similiar functionality to the 'Output' window in VS .Net - i.e. that basically acts like a console window but is proper MDI child of the...
6
by: QuenHo | last post by:
Hi All, I've build a winform application with vb.net which accepts command-line parameters. If I tell windows to open certain files with this application all works fine, but windows does NOT...
0
by: Litani | last post by:
Hi everyone, We have a winform application that uses webservices. It has list screens. The user selects a row from the grid and an edit screen is presented to the user with the selected row. ...
4
by: amgogalla | last post by:
Hi folks, i want ur help for finding the way to call the JAVA API which has commands(helps to communicate a windows application with mainframes application) into .net (winforms) application. we...
0
by: kzWS08 | last post by:
Hello... I have a quick query. Hope someone can help. I have a winform application which uses the Arial Unicode MS font. Is it ok to include the *.ttf font file in my installer? Are there any licence...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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...
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...

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.