Why does a simple ApplicationSetting PropertyBinding for a Form does not work in C#?
Posted
by Mike Rosenblum
on Stack Overflow
See other posts from Stack Overflow
or by Mike Rosenblum
Published on 2010-03-19T15:23:33Z
Indexed on
2010/03/19
15:41 UTC
Read the original article
Hit count: 292
My question involves this simple walkthrough shown in the article Preserve Size and Location of Windows Forms – Part I by Dennis Wallentin.
This approach works 100% fine when using VB.NET. When using the same steps in C#, however, the settings within the Settings tab of the application's properties looks correct, and the app.config file looks right, but the values are not saved when you run it.
The app.config file winds up looking like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="WindowsAppCs.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<WindowsAppCs.Properties.Settings>
<setting name="Location" serializeAs="String">
<value>0, 0</value>
</setting>
<setting name="Size" serializeAs="String">
<value>284, 262</value>
</setting>
</WindowsAppCs.Properties.Settings>
</userSettings>
</configuration>
It looks right to me, but the values do not update when running hosted within Visual Studio or when running the compiled EXE.
I am sure that something very simple needs to be added or done, but I don't know what. Does anyone have any ideas here?
Much thanks in advance...
© Stack Overflow or respective owner