0

I am using Visual Studio 2017 Professional (VS2017) and had a nasty experience for a couple hours caused by VS2017 itself, after I imported a VB.Net project from VS2010 and deleted the app.config file in the new project -- expecting a problem free new app.config file.

The exception being thrown whenever I try to run the project in debug or release is:

"This application has failed to start because the application configuration is incorrect"

Is there something I should look for first?

  • Possible duplicate of ["application has failed to start ... configuration is incorrect" after upgrading?](https://stackoverflow.com/questions/8485425/application-has-failed-to-start-configuration-is-incorrect-after-upgrading) – ehh Jan 03 '19 at 05:34
  • The app.config file was deleted after importing the 2010 project into VS2017, and before saving, quitting, and restarting VS2017, and attempting to compile. However, the newly generated app.config retained the erroneous first line from the older project. . –  Jan 03 '19 at 23:07

1 Answers1

1

A known issue with VS is that, when importing a project from another machine or earlier VS version, etc., VS seems to accept the first line of the provided app.config file, and modifies the rest of the file after you have worked on it for a while. Later on, when you attempt to run in debug or release mode, the project will throw the particular exception you are getting.

If this is what is causing the error, users can resolve this issue simply by changing the first line of the app.config file from:

<?xml version="1.0" encoding="Windows-1252"?>

to

<?xml version="1.0" encoding="utf-8"?>

which has been reported to resolve the issue for this particular case.

(to open the app.config file, just double click on it in the project file listing on the right menu of VS)

Fundamentally, having the wrong xml syntax in the first line of the app.config manifest results in an encoding error, which is commonly caused by using a project from a different computer, different Windows version, earlier version of VS, etc. Unfortunately, users have no idea this error is based on having an incorrect line of code in the app.config file.

Overall, MS needs to modify VS so that it does not freely accept app.config files which will cause an encoding error. The solution would be to determine in VS what correct encoding syntax needs to be written into the app.config for the machine being used.