0

I want to use the the System.Configuration dll for my application. So I made these actions:

  1. Project > Add a new element > Add a Config file

But I couldn't find the .exe.config file in the list so I created a text file and put it in the same folder as the executable file (.exe) of my app and it worked. I could add it to my project.

  1. Then I wanted to import the System.Configuration dll : Project > add a reference

And again I couldn't find the System.Configuration dll in the list so I used the NuGet install console and it worked!

`Install-Package System.Configuration.ConfigurationManager -Version 4.5.0`

My question is: why I can't find the Config file in my Visual C# Element Menu and I'm oblige to create a text document?

Thank you very much for your help. Clement

Clément
  • 25
  • 6
  • For non ASP.NET projects the config file is `app.config` and is copied to the output as `name.exe.config` on build. Manually creating the latter will only lead to it being overwritten. – Richard Apr 09 '20 at 08:27
  • When I ran my app, I didn't have any .exe.config file created in the output, just my .exe file that is why I created one manually. In fact, when I want to use my manually file created .exe.config with ConfigurationManager.AppSettings it doesn't work... – Clément Apr 09 '20 at 08:40
  • Start with an `app.config` in the root of the project, and get the right output file created. Once that is done look at loading the config. (NB. this all assumes this is a .NET Framework project: .NET Core is completely different.) – Richard Apr 09 '20 at 10:32
  • I understood! I realized that I created a Console app projet with the .NET Core... So that why I didn't found the `app.config`. When I created a .NET Framework project I could find this file! Thank you very much @Richard – Clément Apr 09 '20 at 12:18
  • [This link](https://garywoodfine.com/configuration-api-net-core-console-application/) should help you: it does use the command line for project creation, but after that things are the same. – Richard Apr 09 '20 at 12:58

0 Answers0