i'm working on an app that allow users to manage windows programs.
So i have a .exe.config file and contains this:
<?xml version="1.0" encoding="utf-8" ?><configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Control_Desk.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<Control_Desk.Properties.Settings>
<setting name="enabletw" serializeAs="String">
<value>True</value>
</setting>
<setting name="enablelivemail" serializeAs="String">
<value>True</value>
</setting>
<setting name="enabledesktop" serializeAs="String">
<value>True</value>
</setting>
<setting name="enablelogmein" serializeAs="String">
<value>True</value>
</setting>
<setting name="enableps" serializeAs="String">
<value>False</value>
</setting>
<setting name="enablecorel" serializeAs="String">
<value>False</value>
</setting>
<setting name="enablescanner" serializeAs="String">
<value>False</value>
</setting>
</Control_Desk.Properties.Settings>
</userSettings>
And i want to read and change the valeus, but, no sucess, no changes are saved and i cant read any value, when i try, the program throws a System.NullReferenceException, here is my code:
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings["enablelivemail"].Value == "True")
{
config.AppSettings.Settings["enablelivemail"].Value = "False";
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name);
//ConfigurationManager.RefreshSection("appSettings");
}
else
{
config.AppSettings.Settings["enablelivemail"].Value = "True";
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name);
}
So, on second line i got the exception and nothing works, any help?
Thanks in advance!
config.AppSettings on 2nd line reads from <appSettings> node in config file. And there is no <appSettings> node on your config file.
Check this link to solve your problem.
Related
I am trying to create a ComboBox and populate the values using Settings file.
In the first attempt it works but when I try to change the values in Settings file, it is not reflected in the list of items in the ComboBox.
Code Snippets for the same -
ComboBox xaml code -
<ComboBox Name="vGameMode"
ItemsSource="{Binding Source={x:Static p:Settings1.Default}, Path=Modes}"
SelectedIndex="1">
<!-- <ComboBoxItem Content="Personal"/>
<ComboBoxItem Content="Corporate"/> -->
</ComboBox>
Values in Settings File -
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ABC" GeneratedClassName="Settings1">
<Profiles />
<Settings>
<Setting Name="Themes" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>Theme1</string>
<string>Theme2</string>
<string>Theme3</string>
</ArrayOfString></Value>
</Setting>
<Setting Name="DefaultMaxScore" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1000</Value>
</Setting>
<Setting Name="DefaultTimeoutSeconds" Type="System.Int32" Scope="User">
<Value Profile="(Default)">300</Value>
</Setting>
<Setting Name="LeaderboardDays" Type="System.Int32" Scope="User">
<Value Profile="(Default)">7</Value>
</Setting>
<Setting Name="NumberOfTasks" Type="System.Int32" Scope="User">
<Value Profile="(Default)">3</Value>
</Setting>
<Setting Name="CurrentModeIndex" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="DifficultyLevels" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>Medium</string>
<string>Hard</string>
</ArrayOfString></Value>
</Setting>
<Setting Name="GameType" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>Laser Maze</string>
<string>Laser Buster</string>
</ArrayOfString></Value>
</Setting>
</Settings>
</SettingsFile>
Any idea what is wrong here?
I am guessing it is cached somewhere but not sure where.
Make sure you call Settings1.Default.Save() somewhere in there. I forget that all the time.
I need to switch the nodes of two users settings which are saved in app.config at runtime as renaming the key name is not possible. (nodes under WindowsFormsApplication2.Settings2 to WindowsFormsApplication2.Settings1)
I tried to find a solutions by searching the web and tried to use below code to do that but I get error " object reference not set to instance of object" .
Any help would be appreciated.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="WindowsFormsApplication2.Settings2" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="WindowsFormsApplication2.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="WindowsFormsApplication2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<userSettings>
<WindowsFormsApplication2.Settings1>
<setting name="Label1" serializeAs="String">
<value>Label1 FrenchName</value>
</setting>
<setting name="Label2" serializeAs="String">
<value>Label2 French Name</value>
</setting>
</WindowsFormsApplication2.Settings1>
<WindowsFormsApplication2.Settings2>
<setting name="Label1" serializeAs="String">
<value>Label1 English Name</value>
</setting>
<setting name="Label2" serializeAs="String">
<value>Label2 English Name</value>
</setting>
</WindowsFormsApplication2.Settings2>
<WindowsFormsApplication2.Properties.Settings>
<setting name="Label1" serializeAs="String">
<value>Test1</value>
</setting>
</WindowsFormsApplication2.Properties.Settings>
</userSettings>
</configuration>
Source code:
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
configFile.AppSettings.Settings["Settings1"].Value = configFile.AppSettings.Settings["Settings2"].Value;
I am trying you change my default user configuration according to the build profile with slowCheetah, however I am not able to find the right way to use it
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String">
<value>
something
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
I have been trying
<!-- & it's an & escaped in xml-->
<add key="MyApp.Properties.Settings.Url" value="www.google.com" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
but it doesn't work.
How can I do this?
If I get it right, you have this:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String">
<value>
something
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
And you want to transform it to:
(replace <value>something</value> with <value>www.google.com</value>
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String">
<value>
www.google.com
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
The easiest way to do this is to have the following text in your transformation file:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String">
<value xdt:Transform="Replace">
www.google.com
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
It replaces (<value xdt:Transform="Replace">) your <value></value> with the text you want.
Or if you want to select the section to replace with the name="Url" attribute:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<userSettings>
<MyApp.Properties.Settings>
<setting name="Url" serializeAs="String" xdt:Transform="Replace" xdt:Locator="Match(name)">
<value>
www.google.com
</value>
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
We do the same action here (replace: xdt:Transform="Replace") but we reach the value to change by matching an attribute: xdt:Locator="Match(name)"
I have a solution that contains a VB.NET project and a C# project. The VB.NET project is the main one. It references the C# project for user management services. Both connect to the same database. The connection string to this database is stored in the app.config file of the VB.NET project. It also contains other user and application level settings. I am able to read the connection string from the config from inside C# by using the following line of code:
String connectionString = ConfigurationManager.ConnectionStrings["Kais2012.My.MySettings.ConnectionString"].ConnectionString;
One of the other application level properties contained in the config file is called "TeamId". I have written the following code to read it from C#.
String teamId = ConfigurationManager.AppSettings["Kais2012.My.MySettings.TeamId"];
This does not work and I can't figure out why. Any help will be appreciated. Thanks.
The way it doesn't work is that teamId returns null. Here's content of the app.config file.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Kais2012.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Kais2012.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
<CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAnnRg1L0cskebQ8b6DT/j0AQAAAACAAAAAAAQZgAAAAEAACAAAADGL7/5UD/77t+gDIMLQ14qVgAVA9qjBwvafuEDlJdYVwAAAAAOgAAAAAIAACAAAAD40OqR3t0UIxD0ipA99JXk24mbdvRuR8Cz6H0PYectmmACAABG2jSkPRAdCw+AbgevlKkdhx9zW/s+ukhIr58LKeEVwmMFwxxATQxa9kQqP2Ooe11FG+AjkwHBKjzKbc8ZFfu4fobbggTLBT4HHGns1HAaXkozUXgNxdR2D1hrAOBJyjmIZhOVLKu2LHnboncRF7/OTd+zuzORsWia/t14H1qkxAVeyoKwqKCCW4yMIcboDSqzuTvZzzU8wFMCOeYBTdr1sgf80LmXMUMq3HdmN6YURu9lGHxZqL4IBvKuoi0S7wCdJ8WuVZN/ZSC73fQuKGXXT2yM/++W110MJCc5h+cmPO6ooAugFgXRgESR5t3DBhHC9ddBQyXSLr3J2AIKyg6xPOsn1mG6p8w5ibcpfDbblToQPo3kVW7D87jq9CsrCX5B4VnLhDO6qIaf5qVBP5eGqBRzYUu6U/+lpcAelg67N2itQPv9+SnEhqmFWJ90wfs8w+Bakk9LATC8IrdaZP77HIgGYyCpMJ5U8BC9DuIB6tO3BD4E9+nc4Mn03D0hxGxidwjr5DM4i9gU8cutO4V/aEWx8oNw/0oDMmsHPMsTXrniFajOgWwKThDCVtojpuW86R0ShedKYtECIvmgIBSefR1NhHcwGAsIWUy0X95hP/921tJzjTAqaMiMGCB9+0/SkpcybGDg1JW5ljxdlgY0Ad8treC4dFWZW7dCIUynEfY+Xg5lOd96q1jhulpQPj9eJbwy/bFA5gcX+UcaUZL3nIhC2jSm41JMRwKtBlsJHGT3ZhQsTQWLZrmmXO+SGMBzyDDbRvNCdZHJvSuyUCH/Qn9mNkrnvcvsPmxQ8aOI/kAAAABN3SIZqA4kCsK5cY1oI+4aT0K6PX3GgGcubKGvSS9ugEjnkZoHdAdenX2q4BpPIXSyqMvVyc15hB1wHmV8vLbG</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<userSettings>
<Kais2012.My.MySettings>
<setting name="AutoNavigation" serializeAs="String">
<value>True</value>
</setting>
<setting name="UseOsk" serializeAs="String">
<value>False</value>
</setting>
<setting name="AutoHideOsk" serializeAs="String">
<value>False</value>
</setting>
<setting name="StretchReviewColumns" serializeAs="String">
<value>True</value>
</setting>
<setting name="DiscountSkipped" serializeAs="String">
<value>True</value>
</setting>
<setting name="AutoDelay" serializeAs="String">
<value>0</value>
</setting>
<setting name="MinAutoDelay" serializeAs="String">
<value>1000</value>
</setting>
</Kais2012.My.MySettings>
</userSettings>
<applicationSettings>
<Kais2012.My.MySettings>
<setting name="DummyColumn" serializeAs="String">
<value>CreationTime</value>
</setting>
<setting name="PublisherDBName" serializeAs="String">
<value>kais_final</value>
</setting>
<setting name="PublicationName" serializeAs="String">
<value>pbl_kais_WAKHUTU-PC</value>
</setting>
<setting name="SubscriptionDBName" serializeAs="String">
<value>KAISEQ_USER001</value>
</setting>
<setting name="SubscriberServerName" serializeAs="String">
<value>USER001</value>
</setting>
<setting name="PublisherServerName" serializeAs="String">
<value>WAKHUTU-PC</value>
</setting>
<setting name="PublisherLogin" serializeAs="String">
<value>sa</value>
</setting>
<setting name="PublisherPassword" serializeAs="String">
<value>xxxxxx</value>
</setting>
<setting name="UploadToServer" serializeAs="String">
<value>1</value>
</setting>
<setting name="IpAddress" serializeAs="String">
<value>172.23.14.94</value>
</setting>
<setting name="DownloadFromServer" serializeAs="String">
<value>2</value>
</setting>
<setting name="UploadAndDownload" serializeAs="String">
<value>3</value>
</setting>
<setting name="SubscriberPassword" serializeAs="String">
<value>xxxxxx</value>
</setting>
<setting name="PublishingSubscriberServerName" serializeAs="String">
<value>SUP01</value>
</setting>
<setting name="PublishingSubscriberLogin" serializeAs="String">
<value>sa</value>
</setting>
<setting name="PublishingSubscriberPassword" serializeAs="String">
<value>xxxxxx</value>
</setting>
<setting name="PublishingSubscriberDBName" serializeAs="String">
<value>KAISEQ_SUP01</value>
</setting>
<setting name="publishingSubscriberPublicationName" serializeAs="String">
<value>pbl_kais_KAISEQ_SUP01</value>
</setting>
<setting name="SubscriberLogin" serializeAs="String">
<value>sa</value>
</setting>
<setting name="TeamId" serializeAs="String">
<value>2</value>
</setting>
<setting name="DevMode" serializeAs="String">
<value>True</value>
</setting>
<setting name="DevUsername" serializeAs="String">
<value>admin</value>
</setting>
<setting name="DevPassword" serializeAs="String">
<value>admin</value>
</setting>
</Kais2012.My.MySettings>
</applicationSettings>
</configuration>
Use this :
System.Configuration.ConfigurationManager.AppSettings[""]
ConfigurationManager.AppSettings[""]
Refers, specifically, to the the configuration section <appSettings> not to a custom configuration section group named <applicationSettings>. Either move your configuration to the correct section or implement a custom ConfigurationSection and use:
ConfigurationManager.GetSection()
You can mark the settings as public in the C# project ("Access Modifier" in the property pane of settings) and then you can access it from the vb project (don't forget to add the reference).
Dim settings = New ClassLibraryCSharp.Properties.Settings
dim con = settings.ConnectionString
Edit:
Just saw that your question was for the other direction (setting in vb project, read it in c# project). But you can do it also in the other direction.
In my application when I try to get the connection string by using this code :
System.Configuration.ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
It throws an exception that "Configuration System Failed To Initialize". Where is the format of app.config wrong ?
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConStr" connectionString="Integrated Security=false;Persist Security Info=False;User ID=funny;password=veryfunny;Initial Catalog=vegimanager;Data Source=.\sqlexpress;"/>
</connectionStrings>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Vegi_Manager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<userSettings>
<Vegi_Manager.Properties.Settings>
<setting name="FIRMNAME" serializeAs="String">
<value/>
</setting>
<setting name="FIRMADDRESS" serializeAs="String">
<value/>
</setting>
<setting name="FIRMCITY" serializeAs="String">
<value/>
</setting>
<setting name="FIRMSTATE" serializeAs="String">
<value/>
</setting>
<setting name="FIRMPHONE" serializeAs="String">
<value/>
</setting>
<setting name="FIRMMOBILE" serializeAs="String">
<value/>
</setting>
<setting name="FIRMEMAIL" serializeAs="String">
<value/>
</setting>
<setting name="FIRMTIN" serializeAs="String">
<value/>
</setting>
<setting name="FIRMPAN" serializeAs="String">
<value/>
</setting>
<setting name="FIRMMANDITAXNO" serializeAs="String">
<value/>
</setting>
<setting name="INITIALFONFIGDONE" serializeAs="String">
<value>False</value>
</setting>
<setting name="FIRMJURISDICTION" serializeAs="String">
<value/>
</setting>
<setting name="FIRMBANKDETAILS" serializeAs="String">
<value/>
</setting>
<setting name="FIRMDETAILS" serializeAs="String">
<value/>
</setting>
<setting name="BILLFORMATNO" serializeAs="String">
<value>0</value>
</setting>
<setting name="PRINTERNAME" serializeAs="String">
<value/>
</setting>
</Vegi_Manager.Properties.Settings>
</userSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
Try putting the configSections as the first child element of configuration, because configSections should be the first element of configurations
So your config file will go like this:
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Vegi_Manager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<connectionStrings>
<add name="ConStr" connectionString="Integrated Security=false;Persist Security Info=False;User ID=funny;password=veryfunny;Initial Catalog=vegimanager;Data Source=.\sqlexpress;"/>
</connectionStrings>
<userSettings>
<Vegi_Manager.Properties.Settings>
<setting name="FIRMNAME" serializeAs="String">
<value/>
</setting>
<setting name="FIRMADDRESS" serializeAs="String">
<value/>
</setting>
<setting name="FIRMCITY" serializeAs="String">
<value/>
</setting>
<setting name="FIRMSTATE" serializeAs="String">
<value/>
</setting>
<setting name="FIRMPHONE" serializeAs="String">
<value/>
</setting>
<setting name="FIRMMOBILE" serializeAs="String">
<value/>
</setting>
<setting name="FIRMEMAIL" serializeAs="String">
<value/>
</setting>
<setting name="FIRMTIN" serializeAs="String">
<value/>
</setting>
<setting name="FIRMPAN" serializeAs="String">
<value/>
</setting>
<setting name="FIRMMANDITAXNO" serializeAs="String">
<value/>
</setting>
<setting name="INITIALFONFIGDONE" serializeAs="String">
<value>False</value>
</setting>
<setting name="FIRMJURISDICTION" serializeAs="String">
<value/>
</setting>
<setting name="FIRMBANKDETAILS" serializeAs="String">
<value/>
</setting>
<setting name="FIRMDETAILS" serializeAs="String">
<value/>
</setting>
<setting name="BILLFORMATNO" serializeAs="String">
<value>0</value>
</setting>
<setting name="PRINTERNAME" serializeAs="String">
<value/>
</setting>
</Vegi_Manager.Properties.Settings>
</userSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
This is a bit late I know but when I remove this:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
then the error disappears.
This works for me.
Make sure that your app.config or web.config starts with the <configSections> tag inside the <configuration> tab e.g
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
</configSections>
<connectionStrings>
<add name="ConStr" connectionString="Integrated Security=false;Persist Security Info=False;User ID=funny;password=veryfunny;Initial Catalog=vegimanager;Data Source=.\sqlexpress;"/>
</connectionStrings>
<connectionStrings>
after that make sure that the target Framework property of your project is not client profile