0

I was originally writing my program for .NET 4.0... however, recently I changed the target framework for .NET 3.5... the program still works fine, but now I'm running into a rather odd error. In the past, when I built the program, it would generate the .exe and that is it. Now it generates a .exe and a .exe.config.

Should still be fine right? Nope, in the .exe.config file, it has the following code:

<configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        ...
    </sectionGroup>
</configSections>

As you can see, it says Version=4.0.0.0 and because of this, when I run the program I get an unhandled exception assembly error. Its pretty easy to fix, I just delete the .exe.config file and all is well. But its starting to become a pain, to do this on each and every build.

What can I do to fix this?

Jason Axelrod
  • 7,155
  • 10
  • 50
  • 78
  • 3
    Have you manually inspected the csproj files looking for 4.0 references? There may be some lingering elements you need to manually update. – Tejs Apr 30 '12 at 17:33
  • _ for using abusive words.. Removed..... –  Apr 30 '12 at 18:06
  • Switching from 4.0 to 3.5 does not create an app.config; you probably always had one (or added it manually)--which means the .exe.config was always there as well. – Peter Ritchie Apr 30 '12 at 18:17

1 Answers1

1

May be it solve your problem. I have found a some how similar question and its answer is here

Found the answer, delete app.config.

app.config is automatically created based on settings.settings. Visual Studio was not building it, even though it needed to be updated.

Note: Clean and rebuild doesn't force visual studio to clean and rebuild it

Deleting it, to force Visual Studio to rebuild, it fixed it.

Here it is Visual Studio 2010: Properties.Settings broken after retargetting project to .NET Framework 3.5

Community
  • 1
  • 1
Amit
  • 21,570
  • 27
  • 74
  • 94