I am creating a WPF project using .net Core 3.00
, and I am having trouble adding the item appsettings.json
file to my project which is to be used
It's no requirement to switch to an appsettings.json
file in .NET Core. You may still use the very same "old" XML-based App.config
file in a WPF app that targets .NET Core if you want to.
Just add a new configuration file (Project->Add New Item->Application Configuration File) to your project and name it "App.config". If you then add the following contents to it:
...you should be able to get the connection string at runtime using the ConfigurationManager
API:
ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
The default WPF template should include the System.Configuration.ConfigurationManager package by default.