Settings in .NET 2.0
-
Hi, when I create some user scope or application scope settings in assembley which is used as windows library, xml document with settings is generated but I`m not sure what to do after that. Because application uses only default settings which where generated to properity class. When I change any setting in that xml file,they are ignored and app still uses its default values. Can anybody either help me, or point me to some article explaining how to set up windows library settings. Thank you
-
Hi, when I create some user scope or application scope settings in assembley which is used as windows library, xml document with settings is generated but I`m not sure what to do after that. Because application uses only default settings which where generated to properity class. When I change any setting in that xml file,they are ignored and app still uses its default values. Can anybody either help me, or point me to some article explaining how to set up windows library settings. Thank you
The settings are in the app.config file? You have setup the databinding for these controls correct? Do you want the changes to show up as they are changed or when the app restarts?
-
The settings are in the app.config file? You have setup the databinding for these controls correct? Do you want the changes to show up as they are changed or when the app restarts?
App.config is generated for .exe file but what about if I create class library and reference it. Shoud I manualy copy settings for class library to app.config or is there any other way. I dont realy understand the point of settings designer for class library if those settings are not generated.
-
App.config is generated for .exe file but what about if I create class library and reference it. Shoud I manualy copy settings for class library to app.config or is there any other way. I dont realy understand the point of settings designer for class library if those settings are not generated.
You can add an app.config to your library project. This will produce, as an example, mylib.dll.config. If your library has Windows controls though any settings would be stored in the app.config when you bind the control to the application settings. I guess I'm not sure what is your having difficulties with.
-
You can add an app.config to your library project. This will produce, as an example, mylib.dll.config. If your library has Windows controls though any settings would be stored in the app.config when you bind the control to the application settings. I guess I'm not sure what is your having difficulties with.
I try to explain my problem. I add, say, string testString whith default value "abcd" in settings designer of class library test.dll. The string is accesible over Properities.Settings class. It has its default value "abcd" which is generated as an atribute and compiled into library. Now the libary generates test.dll.config file and it includes the testString element. When I copy this test.dll.config to application directory with my class library and change value of testString element to "dcba" and restart application it still uses its default value "abcd". And although that Properties.Settings.testString property is writtable, when I change its value in program and call Save (or there is something like that)on Properties class it will not save it to the test.dll.config. Should this be working and there is some other mistake I'm doing or is this procedure wrong. Thank you
-
I try to explain my problem. I add, say, string testString whith default value "abcd" in settings designer of class library test.dll. The string is accesible over Properities.Settings class. It has its default value "abcd" which is generated as an atribute and compiled into library. Now the libary generates test.dll.config file and it includes the testString element. When I copy this test.dll.config to application directory with my class library and change value of testString element to "dcba" and restart application it still uses its default value "abcd". And although that Properties.Settings.testString property is writtable, when I change its value in program and call Save (or there is something like that)on Properties class it will not save it to the test.dll.config. Should this be working and there is some other mistake I'm doing or is this procedure wrong. Thank you
Ok I understand now. I made a test library with a user control containing a label, textbox and button. Everything seems fine to me.
private void button1_Click(object sender, EventArgs e) { global::LibControls.Properties.Settings.Default.LabelText = textBox1.Text; global::LibControls.Properties.Settings.Default.Save(); global::LibControls.Properties.Settings.Default.Reload(); }
-
Ok I understand now. I made a test library with a user control containing a label, textbox and button. Everything seems fine to me.
private void button1_Click(object sender, EventArgs e) { global::LibControls.Properties.Settings.Default.LabelText = textBox1.Text; global::LibControls.Properties.Settings.Default.Save(); global::LibControls.Properties.Settings.Default.Reload(); }