Adding reference to System.Configuration in Visual Studio 2008

To add a reference of System.Configuration/ Configuration in Visual Studio 2008
# In Solution Explorer, right-click the project node and click Add Reference.
# In the Add Reference dialog box, select the .NET tab and select System.Configuration from the list and then click OK.

Configuration 1
Figure: Step 1
Confiugaration2
Figure: Step 2
This code snippet shows how to use Configuration Settings from App.Config file.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace ConfigurationManagerExample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string connectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
            MessageBox.Show(connectionString);
        }
    }
}


You can download source code.
Thanks
A Rahim Khan

Advertisements
    • siva
    • June 30th, 2014

    Really Thank you so much

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: