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

System.Configuration Save Does Not Save

SR
I am trying to use the Configuration object provided with the .NET 2.0
framework. I see that when I call the Save function it does update the
<application>.exe.config file. However, when I close the application and
check the <application>.exe.config file again, it has reverted back to how
it was when the application was started.

Is there something I am doing or not doing? Here is part of my code: (And
before anyone writes it, I know I can use the DatabaseConfiguration object,
but this is simply for learning this object at this point.)

Thanks!

My Config Class:

Public Class FileGenClass : Inherits ConfigurationSection

<ConfigurationProperty("DatabaseServer")> _
Public Property DatabaseServer() As String
Get
Return Me.Item("DatabaseServer")
End Get
Set(ByVal value As String)
Me.Item("DatabaseServer") = value
End Set
End Property

<ConfigurationProperty("DatabaseName")> _
Public Property DatabaseName() As String
Get
Return Me.Item("DatabaseName")
End Get
Set(ByVal value As String)
Me.Item("DatabaseName") = value
End Set
End Property

<ConfigurationProperty("DatabaseUser")> _
Public Property DatabaseUser() As String
Get
Return Me.Item("DatabaseUser")
End Get
Set(ByVal value As String)
Me.Item("DatabaseUser") = value
End Set
End Property

<ConfigurationProperty("DatabasePassword")> _
Public Property DatabasePassword() As String
Get
Return Me.Item("DatabasePassword")
End Get
Set(ByVal value As String)
Me.Item("DatabasePassword") = value
End Set
End Property
....

Saving Code:

Try
moFileGen =
CType(ConfigurationManager.GetSection("DatabaseSet tings"), FileGenClass)

If moFileGen Is Nothing Then
moFileGen = New FileGenClass
Dim oSettings As New Settings
oSettings.btnCancel.Enabled = False
If oSettings.ShowDialog(Me) = Windows.Forms.DialogResult.OK
Then
moFileGen.DatabaseServer = oSettings.txtDBServer.Text
moFileGen.DatabaseName = oSettings.txtDBName.Text
moFileGen.DatabaseUser = oSettings.txtUser.Text
moFileGen.DatabasePassword = oSettings.txtPassword.Text

Dim oConfig As Configuration =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None)
oConfig.Sections.Add("DatabaseSettings", moFileGen)
oConfig.Save()
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
....
Apr 28 '06 #1
0 1603

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

Similar topics

1
by: Supra | last post by:
i got "system error" when saving to xml file. i am using checkbox1 control to xml. when user clicked checkbox and set to true and press btnOk to conform and save it to xml ...
0
by: Supra | last post by:
i got "system error" when saving to xml file. i am using checkbox1 control to xml. when user clicked checkbox and set to true and press btnOk to conform and save it to xml ...
0
by: Andrzej Kaczmarczyk | last post by:
Hello, I am having troubles saving configuration file. I did the folloing: inherited from ConfigurationSection, ConfigurationCollection, ConfigurationElement to define my own element in...
0
by: phillip | last post by:
This is interesting, I have attached my web.config file and the exception I have been logging. I created a library which provide data access to a database and a control system. The library is...
0
by: cyberstrike | last post by:
In the system.configuration namespace, is there any way to save a Dataset or any other custom structure in a section? I know how to make a class and derive it from the section class; however, any...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
8
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
1
by: Shannon Richards | last post by:
Hello All: I have implemented a custom configuration section in my app.config file as follows: <configSections> <section name="AdminUIConfig" type="TestMgr.UIConfigSection,TestMgr"/>...
0
by: Shaikh shahnawaz | last post by:
Hi, I have implement multiple file uploading progress bar with the help of flash and .net file is upload on my local machine but not working with server it's give error while uploading image on...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.