Visual Studio | VB.NET | MyApp.config vs MyApp.exe.config

jim brown 271 Reputation points
2021-01-22T21:05:41.533+00:00

Is there a way to default MyApp.exe to use MyApp.config rather than MyApp.exe.config? I was using .net framework 3.5 and my app used MyApp.config but now that I have upgraded my .net framework to 4.x the app will not load unless I rename MyApp.config to MyApp.exe.config.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,710 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,401 Reputation points
    2021-01-22T23:13:55.933+00:00

    Hello @jim brown

    The name of the configuration file is internal to the .NET Framework and can not be changed. What I've done in the past and will not suit many other developer needs is to avoid using app.config and instead using a .json file which circumvents app.config while at the same time places you in complete control.

    I have a sample project showing both conventional and json configuration.

    https://github.com/karenpayneoregon/visual-basic-getting-started/tree/master/MySettingsAlternate

    0 comments No comments

  2. Duane Arnold 3,221 Reputation points
    2021-01-22T23:56:00.06+00:00

    MyApp.exe.config is the runtime config file .NET is looking for that must be in the same location as the MyApp.exe program is located, which is created from the Myapp.config in the root project, the Windows form project, upon the successful build of the project.

    An app.config in a project is only used when the project is run in debug mode.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.