|
-
Aug 28th, 2006, 11:33 AM
#1
Thread Starter
Addicted Member
[RESOLVED]Adding Property to My.Settings @ runtime
This is the code...
VB Code:
Dim prop As System.Configuration.SettingsProperty = New System.Configuration.SettingsProperty(TreeView1.SelectedNode.Parent.ToString)
My.Settings.Properties.Add(prop)
My.Settings.Save()
The problem is that the property isnt added to the Settings. Does anyone know how to add a Property to the user settings?
Thanx, Figa
Last edited by figa; Aug 28th, 2006 at 05:26 PM.
-
Aug 28th, 2006, 11:34 AM
#2
Re: Adding Property to My.Settings @ runtime
How do you know it's not being added?
-tg
-
Aug 28th, 2006, 11:36 AM
#3
Thread Starter
Addicted Member
Re: Adding Property to My.Settings @ runtime
If i go to the project properties, then to the settings window, i can see its not being added...
-
Aug 28th, 2006, 11:42 AM
#4
Re: Adding Property to My.Settings @ runtime
you do realize that you won't see anything added to that when you run the application because the settings file that you'd be looking at isn't the same one
-
Aug 28th, 2006, 11:44 AM
#5
Re: Adding Property to My.Settings @ runtime
for instance here is the path of the settings file for a project i'm working on is
C:\Documents and Settings\dklingman\Application Data\CSSI\EmailPollingService.vshos_Url_yugefftfbxq401mle51pngzdbyfsghsm\1.0.0.55
that's where the file is located durning runtime
-
Aug 28th, 2006, 12:06 PM
#6
Thread Starter
Addicted Member
Re: Adding Property to My.Settings @ runtime
Hi, do you have a small piece of code about adding and saving settings?
Thanx
-
Aug 28th, 2006, 12:24 PM
#7
Re: Adding Property to My.Settings @ runtime
Here's what you have to realize.... the code it right.... the property is being added.... BUT... when you look at the Project Properties... it reads its values from the App.Config that is in the project root folder. But that's not the file that actualy gets read during runtime.... If you look in the bin folder... you should see a applicationname.exe.config file... THAT is the config file during run-time. Now here's the kicker... if you make changes to the app.config in the project root.... and run your applicaiton, the newer app.confg file will OVERWRITE the older appname.exe.config file. That means you will lose anything that is in the appname.exe.config file.
-tg
OG Tay sez: yo!
-
Aug 28th, 2006, 12:30 PM
#8
Thread Starter
Addicted Member
Re: Adding Property to My.Settings @ runtime
(I just read your post again, and i think you just described what im saying . Is there a workaround ?)
But it will overwrite with the old not changed data right..? So nothing is lost.
I just want to add some setting i want to save give it a value and save it. Now i can add a property on runtime, if i count it it all went right, but when i start my program again, the new property is gone...
Ill be back late, i appreciate the help, but im no longer online. Anyway thanx, and if i dont forget ill post the answer.
Figa
-
Aug 28th, 2006, 03:23 PM
#9
Re: Adding Property to My.Settings @ runtime
The workaround it to add it in design time from the start....but that doesn't sound like what you want.
The reason the property is gone the next time you run it is because the IDE takes the app.config file and copies it to the bin folder when you run your app. After running your app, if you "Show All Files" ... look in the bin directory. You should see a file appname.vshost.exe.config.... open it up.... look in there, you;ll find the settings for your added property. But the next time you run your app, that file will get overritten by the file that is in your project's root folder... making it appear to be gone.
-tg
-
Aug 28th, 2006, 05:26 PM
#10
Re: Adding Property to My.Settings @ runtime
This is ridiculous. There is no workaround because there is no problem. Your code is working exactly as it should be. If you're recompiling your project over and over then of course you're losing the changes you're making at run time. When your app is deployed though, you won't be recompiling each time the app is run so any changes you make will be permanent. If you want to prove to yourself that this is the case then compile a Release build and run it a couple of times directly from Windows Explorer. You'll see that any changes you make will be persisted to the next session.
-
Aug 28th, 2006, 05:26 PM
#11
Thread Starter
Addicted Member
Re: Adding Property to My.Settings @ runtime
Thanx for the info, but this way the User and Application mode arent that different. Ill will make my own settings file then, thanks.
Figa
(just read your post jim, is there a way that i can see in it saves in my enviroment?)
Last edited by figa; Aug 28th, 2006 at 05:31 PM.
-
Aug 28th, 2006, 09:12 PM
#12
Re: [RESOLVED]Adding Property to My.Settings @ runtime
*Sigh* .... figa - you hear us, but you're not listening.... it's the way it works... that's just the way it is. As long as you continue to run the app in the IDE, the config file will be OVERWRITTEN every time... there is NO workaorund, because as jmc said, there is no problem. Your code is working. I don't know what else we can tell you.
-tg
OG Tay sez: Duuuude! Sweeeeet!
-
Aug 29th, 2006, 06:18 AM
#13
Thread Starter
Addicted Member
Re: [RESOLVED]Adding Property to My.Settings @ runtime
Well then, thats just lame....So i have to make a redistubutable everytime i want to see if its stores the right value...that sucks, but thanks
We're done
-
Aug 29th, 2006, 08:43 AM
#14
Re: [RESOLVED]Adding Property to My.Settings @ runtime
Arrrgh! No you don't..... Click your project.... click "Show All Files" .... go into the bin directory.... find the appname.vshost.exe.config file.... OPEN it.... look...
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|