Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > .NET Framework 1.x
|
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2007, 04:04 PM
Authorized User
 
Join Date: Sep 2007
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default can we use Configuration, ConfigurationManager in

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.
Code:
Imports System.Configuration

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        Dim config As Configuration

        config = ConfigurationManager.OpenExeConfiguration(Application.StartupPath + "\Program1.exe")
                                       config.AppSettings.Settings.Remove("inactivity")
        config.AppSettings.Settings.Add("inactivity", udInactivity.Value.ToString())

        If (axChkterminals.Checked = True) Then
              config.AppSettings.Settings.Remove("chkallterminals")
             config.AppSettings.Settings.Add("chkallterminals", str)
        Else
             config.AppSettings.Settings.Remove("chkallterminals")
             config.AppSettings.Settings.Add("chkallterminals", str)
        End If

        If (axChkMonday.Checked = True) Then
                str = "monday" + "," + udHoursMonday.Value.ToString() + "," + udMinsMonday.Value.ToString() + "," + udHoursToMonday.Value.ToString() + "," + udMinsToMonday.Value.ToString()
            config.AppSettings.Settings.Remove("monday")
            config.AppSettings.Settings.Add("monday", str)
       Else
            config.AppSettings.Settings.Remove("monday")
       End If

       If (MessageBox.Show("Are you sure you want to save?", "Calendar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes) Then
                    config.Save()
                    MessageBox.Show("Configuration File has been saved!")
       End If

End Sub

Public Function LoadConfigValues() As String
    Dim config As Configuration

    config = ConfigurationManager.OpenExeConfiguration(Application.StartupPath + "\Program1.exe")

    inactivityTime = Convert.ToDecimal(config.AppSettings.Settings("inactivity").Value)

    CheckAllTerminals = Convert.ToDecimal(config.AppSettings.Settings("chkallterminals").Value)

    day = config.AppSettings.Settings("monday").Value.ToString().ToLower()
                If (day.Split(splitter)(0).ToLower() = "monday") Then
                    config_DaysList.Remove("monday")
                    config_DaysList.Add("monday", day)
                End If

End Function
And the same type of program i need to do now in Vb.net 2003. but i can use Configuration inside 2003. when i tried to add reference instead of "System.Configuration" its "System.configuration.install". and i add that and tried the same codes above to my Vb.net 2003 program.

but in this lines error occurs as Type expected.
Code:
Dim config As Configuration
and in this lines error occurs as Name 'ConfigurationManager' is not declared.
Code:
config = ConfigurationManager.OpenExeConfiguration(Application.StartupPath + "\Program1.exe")
whether i can use "Configuration" in 2003.if you have anyidea what's wrong please let me know. if you can please help me.

Thanks in advance.
 
Old February 20th, 2008, 09:18 AM
Registered User
 
Join Date: Feb 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

use ConfigurationSetting instead of ConfigurationManager.

Thanks and Regards
Harikesh Sharma





Similar Threads
Thread Thread Starter Forum Replies Last Post
ConfigurationManager.ConnectionSettings.add() stubid_cat BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 3 February 25th, 2007 08:58 PM
12-1 ConfigurationManager shysusan BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 5 February 13th, 2007 12:42 AM
Configuration Problem azmatazz Biztalk 3 December 22nd, 2005 11:39 AM
Configuration files hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 2 March 23rd, 2005 09:13 AM
MYSQL Configuration randbert96310 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 9 June 24th, 2004 07:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.