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:
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(Applicat ion.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("chkallterminal s")
config.AppSettings.Settings.Add("chkallterminals", str)
Else
config.AppSettings.Settings.Remove("chkallterminal s")
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(Applicat ion.StartupPath + "\Program1.exe")
inactivityTime = Convert.ToDecimal(config.AppSettings.Settings("ina ctivity").Value)
CheckAllTerminals = Convert.ToDecimal(config.AppSettings.Settings("chk allterminals").Value)
day = config.AppSettings.Settings("monday").Value.ToStri ng().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(Applicat ion.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.
2 2749
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:
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(Applicat ion.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("chkallterminal s")
config.AppSettings.Settings.Add("chkallterminals", str)
Else
config.AppSettings.Settings.Remove("chkallterminal s")
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(Applicat ion.StartupPath + "\Program1.exe")
inactivityTime = Convert.ToDecimal(config.AppSettings.Settings("ina ctivity").Value)
CheckAllTerminals = Convert.ToDecimal(config.AppSettings.Settings("chk allterminals").Value)
day = config.AppSettings.Settings("monday").Value.ToStri ng().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(Applicat ion.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.
Try using ConfigurationSettings instead of ConfigurationManager. ConfigurationManager replaced ConfigurationSettings when they released VS 2005.
Nathan
thanks a lot for your reply and help...
but as i said in my earlier post, i can't even use Configuration. when i give dim gConfig as configuration , then error is there - type excepeted. so how can i use configurationsettings without declaring configuration.
i'm new to programming. so if you can please give me some more information. and if you can provide some examples, then it will be a great help for me.
thanks in advance.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason |
last post by:
Hi,
I'm trying to integrate Microsoft's Configuration Management
Application Block (CMAB), and have run into a bit of trouble. Would
appreciate any input anybody could provide at this point. I...
|
by: Jorgas |
last post by:
Hi!
I try to use the configuration application block from the Enterprise Library
and have done prework as specified from one of the hands-on labs from that
package. When trying to get...
|
by: Alberto |
last post by:
Can you tell me how to read and modify a value in the app.config file using
this class?
Thank you very much
|
by: Jyothi Kumar |
last post by:
Hi, my project is a migrated project from VS 2003 to VS 2005, in this project I used System.Configuration.ConfigurationSettings.AppSettings, now in VS 2005 it is giving a warning Message like:...
|
by: =?Utf-8?B?RG91Z2llIEJyb3du?= |
last post by:
Hi
I've written custom configuration section (inherits from
System.Configuration.ConfigurationSection) to simplify the contents of the
config file and to make life easier when accessing them in...
|
by: =?Utf-8?B?Vmlua2k=?= |
last post by:
I keep getting this warining in my code, but when i tried to look at the
intellisense after system.configuration. , I couldn't find
configurationManager but when i forced to put...
|
by: =?Utf-8?B?U3VzYW4=?= |
last post by:
We are trying to move to a 64 bit architecture, but I'm still having some
issues. I have the code with the 32 bit version of Oracle working fine on a
64 bit computer with Windows Server 2003 (also...
|
by: pantagruel |
last post by:
Hi,
I have a Visual studio 2005 project that runs as a Windows Service. In
it I have declared that I am using System.Configuration.
I have set one application setting for the service using the...
|
by: Thomas Bauer |
last post by:
Hello,
I have a config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Directory" value="C:\_Database\" />
<add key="CloseApplication" value="0" />...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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...
|
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,...
| | |