Application settings error after changing target framework of project
Asked Answered
K

5

16

In my application I am using user settings as explained here. Then I realized that in VS 2010 I was using .NET 4.0 while only .NET 2.0 was sufficient.

When I changed the framework and build the project, in my code whenever I access setting now, I get the following error:

An error occurred creating the configuration section handler for userSettings/Vegi_Manager.Properties.Settings: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. (C:\Users\AKSHAY\AppData\Local\Microsoft\Vegi-Manager.vshost.exe_Url_44035dlkzpfaaauiqsd4nh3f0l0yq0tv\1.0.0.0\user.config line 5)

It is for unknown reasons using version 4.0. Please suggest what should I do.

Kolva answered 20/6, 2011 at 8:0 Comment(0)
P
18

Check out your app.config maybe you still have System.Configuration.UserSettingsGroup or something of that sort of version 4 still lurking around, you will have to manually edit and get the relevant for version 2

Pulmotor answered 20/6, 2011 at 8:7 Comment(2)
I had this in my app.config : sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"Kolva
@Pulmotor i had changed to version 2 if i change 2 it shows Could not load file or assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' how can i solve this.Stine
P
9

I was having the same problem having started developing my Outlook add-in in Visual Studio 2010 targeting the .NET 4.0 framework and then deciding to change it to the 3.5 framework. It seems Visual Studio was NOT smart enough to update my app.config file which still had a reference to 4.0.

As previous posters have suggested (I'll be just a little bit more specific), by manually editing app.config to change all references from "Version=4.0.0.0" to "Version=2.0.0.0" (apparently .NET 3.5 still uses 2.0.0.0) in the <sectionGroup> element and its child elements, I was able to get the settings working again in my case.

Panthea answered 1/2, 2013 at 23:6 Comment(0)
P
4

It is likely that you have a reference to a .NET 4 assembly in your solution - if you open the "Add Reference" window in your solution and make the window a bit wider, you will see that there are columns for Version and Runtime... when you created your solutions to target .NET 4, you might have added a reference to an assembly that requires the .NET 4 runtime and now you have changed to .NET 2, you need to swap it for an assembly that only needs the .NET 2 runtime.

Of course, if you have used something form the .NET 4 assembly that didn't exist in .NET 2, you will either have to re-write to avoid using it or change your mind and do it in .NET 4 instead!

Phenobarbitone answered 20/6, 2011 at 8:11 Comment(1)
Thanks Sohnee, It was a fault in app.configKolva
B
2

if you open your app.config, make sure all the config sections are targeting .net framework 2 not 4

if you post your app.config to me i can help more

Babettebabeuf answered 20/6, 2011 at 8:38 Comment(0)
C
2

May I add here that you need to change the app.config details / references to the previous .NET framework (in this case 4.0.0.0) to the new System refence .NET version (in this case 2.0.0.0 which is the same for .NET 3.5!)

Chorister answered 9/4, 2012 at 16:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.