面向 Windows 桌面技术的项目(例如 Windows Presentation Foundation 或 Windows 窗体)可能包含 Web 浏览器控件。 提供的 Web 浏览器控件很可能是在 HTML5 和其他现代 Web 技术之前设计的,现在已过时。 Microsoft 发布了 Microsoft.Web.WebView2NuGet 包 作为 Web 浏览器控件的现代替代品。
using Microsoft.Extensions.Configuration;
internal class Program
{
internal static IConfiguration Config { get; private set; }
private static void Main(string[] args)
{
Config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
// Use the config file to get a connection string
string? myConnectionString = Config.GetConnectionString("database");
// Run the rest of your app
}
}
Imports Microsoft.Extensions.Configuration
Module Program
Private _config As IConfiguration
' Shared not required since Program is a Module
Friend Property Config As IConfiguration
Get
Return _config
End Get
Private Set(value As IConfiguration)
_config = value
End Set
End Property
Sub Main(args As String())
Config = New ConfigurationBuilder() _
.AddJsonFile("appsettings.json") _
.Build()
' Use the config file to get a connection string
Dim myConnectionString As String = Config.GetConnectionString("database")
' Run the rest of your app
End Sub
End Module