我正在尝试使用 WPF(Core3)扩展现有的aspnetZero解决方案。 当我运行项目时,调试器以0 erreur退出,我继续输出以下消息:
The program '[12936] Guichet.WPF.exe' has exited with code -42 (0xffffffd6).
任何人都知道此消息意味着什么吗?
我已查明了触发错误的代码:
private static IConfigurationRoot BuildConfiguration(string path, string environmentName = null, bool addUserSecrets = false)
{
var builder = new ConfigurationBuilder()
.SetBasePath(path)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
if (!environmentName.IsNullOrWhiteSpace())
{
builder = builder.AddJsonFile($"appsettings.{environmentName}.json", optional: true);
}
builder = builder.AddEnvironmentVariables();
if (addUserSecrets)
{
builder.AddUserSecrets(typeof(AppConfigurations).GetAssembly());
}
IConfigurationRoot config =builder.Build();
return config;
}
}
通常,该应用基于ConfigurationBuilder构建的配置设置,这里我有我的 appsetting.json :
{
"ConnectionStrings": {
"Default": "Server=localhost; Database=GuichetDb; Trusted_Connection=True;"
},
"AbpZeroLicenseCode": "00Ja8fNTz2jV9ZcsOXrCNg8fzIkxYtVIne35e9b42078696e68c4c5299369f00699"
}
我本可以使用以下命令查看我的连接字符串值:
var CS=config["Default"];
Console.Write(CS);
但是我在CS中没有输入空值?
通常在 SetBasePath 中,构建器会设置appsettings所在的路径,我的appsettings.json存在于 F:\ tfs \ Guichet \ V3.1 \ WpfApp1 ,但调试时函数中我的路径值为 “ F:\ tfs \ Guichet \ V3.1 \ src \ WpfApp1 \ bin \ Debug \ netcoreapp3.0” < / em> 。