skip to Main Content

I started using Visual Code instead of VS- Unfortunately, I can’t figure out how to setup appSettings.config and reference the key values using Configuration Manager.

This line throws a Nullreference exception:

var applicationId = ConfigurationManager.AppSettings["appId"].ToString();

I manually added the file appSettings.config when I created the console application. Here’s the Folder structure:

enter image description here

Is there additional configuration needed?

2

Answers


  1. Chosen as BEST ANSWER

    I needed to rename appsettings.config to app.config.


  2. Why don’t you use Visual Studio 2022 where all of that is in the box?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search