gpt4 book ai didi

.net - 找不到库 hostpolicy.dll

转载 作者:太空宇宙 更新时间:2023-11-04 12:28:16 24 4
gpt4 key购买 nike

我有一个简单的 .NET Core 项目(控制台应用程序),我正在尝试编译和运行它。 dotnet build 成功,但是当我执行 dotnet run 时出现以下错误:

dotnet run
Project RazorPrecompiler (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in [path].

我的 project.json 看起来像这样:

{
"buildOptions": {
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNetCore.Razor": "1.0.0",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"description": "Precompiles Razor views.",
"frameworks": {
"netcoreapp1.0": {
"imports": [ ]
}
},
"version": "1.2.0"
}

什么是 hostpolicy.dll,为什么会丢失?

最佳答案

dotnet core 2.0 及更高版本的更新:文件appname.runtimeconfig.json(用于调试和发布配置)需要位于与相同的路径中appname.dll.

它包含:

{
"runtimeOptions": {
"tfm": "netcoreapp2.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "2.0.0"
}
}
}

然后 dotnet.exe exec "path/to/appname.dll"[appargs] 工作。

关于.net - 找不到库 hostpolicy.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43995069/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com