Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application settings error after changing target framework of project

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.

like image 659
Akshay J Avatar asked Jun 20 '11 08:06

Akshay J


5 Answers

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

like image 186
V4Vendetta Avatar answered Nov 18 '22 04:11

V4Vendetta


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.

like image 42
public wireless Avatar answered Nov 18 '22 04:11

public wireless


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!

like image 4
Fenton Avatar answered Nov 18 '22 04:11

Fenton


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

like image 2
Hesham Avatar answered Nov 18 '22 04:11

Hesham


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!)

like image 2
nepaluz Avatar answered Nov 18 '22 05:11

nepaluz