我们正在使用.net core 3.0和C#构建更大的解决方案,其中的一个项目是输出exe的控制台应用程序。我最近才开始研究它,但是无法使其运行。当我在Visual Studio(2019,版本16.3.10,在Windows 10上运行)中以调试模式启动它时,收到以下消息:
Invalid runtimeconfig.json [C:\loong-path\projectname\bin\Debug\netcoreapp3.0\projectname.runtimeconfig.json] [C:\loong-path\projectname\bin\Debug\netcoreapp3.0\projectname.runtimeconfig.dev.json]
C:\loong-path\projectname\bin\Debug\netcoreapp3.0\projectname.exe (process 3312) exited with code -2147450733.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
在查看时,runtimeconfig.json
它似乎非常简单且正确:
{
"runtimeOptions": {
"tfm": "netcoreapp3.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.0.0"
}
}
}
对于runtimeconfig.dev.json
:
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\myusername\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\myusername\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
}
我已经尝试过在构建之前进行清理,并在构建之前删除bin文件夹,但是runtimeconfig.json
重新生成的内容看起来是一样的。
我已经尝试通过dotnet从控制台运行它,但是获得的输出基本上与Visual Studio相同。即使在将详细程度设置为诊断的情况下运行它时,也会产生相同的输出(dotnet run --no-build --verbosity diagnostic
),这并不是很有帮助。当我projectname.exe
直接运行结果时,也会发生同样的情况。
我相当确定该程序应该可以工作,但是还有其他一些潜在的错误,因为同一修订版可以在另外两个人的计算机上工作。但是我真的很努力地找出问题所在,因为自动生成的runtimeconfig.json
文件似乎并不是问题所在。
dotnet
直接dll
在bin文件夹中像这样运行会产生实际错误消息:C:\loong-path\projectname\bin\Debug\netcoreapp3.0> dotnet projectname.dll
。
(潜在错误为:
...
Unhandled exception. System.Exception: Failed to find or load OtherProjectName X509 certificate from local computer/personal certificate store.
---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
at System.Security.Cryptography.X509Certificates.X509CertificateCollection.get_Item(Int32 index)
at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.get_Item(Int32 index)
...
这是由此引起的:
var otherProjectNameClientCertificateColl = certificateStore
.Certificates
.Find(X509FindType.FindByThumbprint, _otherProjectNameCertificateStoreThumbprint, true);
var otherProjectNameClientCertificate = otherProjectNameClientCertificateColl[0];
(这是最后一行失败。)
)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句