473,769 Members | 7,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to retrieve appsetings in WinForm Application?

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

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

.....

I use
txtSubject.Text =
ConfigurationMa nager.AppSettin gs["MailSubjec t"].ToString();

But it can't compile.

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

you should use

System.Configur ation.Configura tionSettings.Ap pSettings["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:

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

....

I use
txtSubject.Text =
ConfigurationMa nager.AppSettin gs["MailSubjec t"].ToString();

But it can't compile.

How can I retrieve appsetings in WinForm applicaiton


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

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

....

I use
txtSubject.Text =
ConfigurationMa nager.AppSettin gs["MailSubjec t"].ToString();

But it can't compile.

How can I retrieve appsetings in WinForm applicaiton


It should be ConfigurationSe ttings.AppSetti ngs, not
ConfigurationMa nager.AppSettin gs.

--
Jon Skeet - <sk***@pobox.co m>
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 ConfigurationSe ttings is obsoleted.

"Jon Skeet [C# MVP]" <sk***@pobox.co m>
???????:MP***** *************** ****@msnews.mic rosoft.com...
ad <fl****@wfes.tc c.edu.tw> wrote:
I have define some appsetings in ap.config like:

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

....

I use
txtSubject.Text =
ConfigurationMa nager.AppSettin gs["MailSubjec t"].ToString();

But it can't compile.

How can I retrieve appsetings in WinForm applicaiton


It should be ConfigurationSe ttings.AppSetti ngs, not
ConfigurationMa nager.AppSettin gs.

--
Jon Skeet - <sk***@pobox.co m>
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:
<configuratio n> <appSettings> <add key="MailBody"
value="Test Mail body"/> </appSettings> </configuration>
I use: txtSubject.Text =
ConfigurationMa nager.AppSettin gs["MailSubjec t"].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.configur ation.dll [2.0]
// using System.Configur ation.
string s = ConfigurationMa nager.AppSettin gs["MailBody"];
ciao Frank
--
Dipl.Inf. Frank Dzaebel [MCP/MVP C#]
http://Dzaebel.NET
Nov 17 '05 #5
ad <fl****@wfes.tc c.edu.tw> wrote:
I am using VS2005, it say that the ConfigurationSe ttings is obsoleted.


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

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

using System;
using System.Configur ation;

public class Test
{
static void Main()
{
Console.WriteLi ne (ConfigurationM anager.AppSetti ngs["Foo"]);
}
}

Test.exe.config :
<?xml version="1.0" ?>
<configuratio n>
<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.co m>
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
2330
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 want to have complete control over the UI - no visibly embedded Media Player if possible. I also need to be able to programatically stop/play/pause/resume/change volume/change songs. Any ideas on how to do this? Do I need some sort of...
1
1792
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 running this application by typing the URL of the virtual directory (and name of my application), the assemblies are getting downloaded to my machine's GAC but the application is giving error that cannot find the configuration file. Is there any way...
9
3271
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 time. Please help! Dayne
0
2935
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 Winform code --------------- Browser.DocumentHTML = ""; string HTMLData="";
1
2154
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 main winform application and does not look like a DOS window :). I have tried using an RTF but that was not particularly great when a lot of information is displayed quickly. I don't want to know how to show a console window using the...
6
1696
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 show the application name in the short-cut menu or in the dialog "choose program" as it does for other programs. I've set all assembly settings in the assemblyinfo file I could find, but that doesn't help. Where should I define the name???
0
1278
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. Switching from the list screen to edit is slow if I have decent amount of controls. I can see the screen painting. In some cases, I can see the application painting some controls read only or disabled. Any suggestions on how to display the...
4
1873
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 developed the .net application and we have the JAVA api which was given by others . Here , we need to call that java API , to communicate with the other system(Mainfarme system). Can any one tell me with lines of code how can we resolve this issue...
0
967
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 restrictions that I should be aware of or is it ok to redistribute as part of my application? Many thanks.
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9977
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9848
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
8860
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5432
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3947
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
3549
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
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.