Cannot add appsettings.json inside WPF project .net core 3.0

前端 未结 3 370
梦谈多话
梦谈多话 2020-12-29 09:06

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

3条回答
  •  一生所求
    2020-12-29 09:31

    add an App.config file to the root of your project and add this code:

    
    
    
      
        
      
    
      
        
      
    
    
    

    appSettings is with S not s

    Now you can read these anywhere of your dotnet core wpf app:

    string DefaultLanguage = ConfigurationManager.AppSettings.Get("DefaultLanguage"); 
    string ConnectionString = ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString;
    

提交回复
热议问题