I have someone else\'s WPF-based .NET 3.5 app that I\'m attempting to update to .NET 4.5. The code ran fine under .NET 3.5, and I\'m running Visual Studio 2013 Express on Wi
Check the spellings of connectionStrings
,connectionString=""
if used!
'S' should be capital ..XML is case sensitive :)
I solve this problem by moving startup section in app.config to the last part before </configuration>
, startup section must be the last part in app.config, like this:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Digging Deeper into the Exception Details down to the last InnerException, and I found this:
"Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element"
Move configSections to the beginning
Check app.config file make sure that you don't have configurations to lib(s) that you no longer use or you have removed from the project
Late to the party, but found this reason in my case. I had added a key-value
pair with appSettings
in app.config
as in
<appSettings>
<add key="EncryKey" value="MyKey"/>
</appSettings>
before <configSections>
. Upon digging in the internet, I came to know that, <configSections>
had to be at the top of the root
, soon after <configuration>
and rest of the orders are irrelevant. Moving appSettings
below <configSections>
helped me fix this issue.
One (not very educational) workaround would be to start a new 4.5 project, and copy-paste the relevant pieces of code from the old one.