[英].Net Core can't load hostpolicy.dll (HRESULT: 0x800700C1)
I'm in the middle of upgrading my project from .Net Core 2.2 to 3.1, but I've ran into some issues.我正在将我的项目从 .Net Core 2.2 升级到 3.1,但我遇到了一些问题。 At first, by starting via the command line, I got an error message that the hostpolicy.dll couldn't be found in the output folder.
首先,通过命令行启动,我收到一条错误消息,指出在输出文件夹中找不到 hostpolicy.dll。 To fix that I installed
Microsoft.NETCore.DotNetHostPolicy
, but now I'm getting this error message:为了解决这个问题,我安装了
Microsoft.NETCore.DotNetHostPolicy
,但现在我收到此错误消息:
Failed to load the dll from [*path*\win-x86\hostpolicy.dll], HRESULT: 0x800700C1
An error occurred while loading required library hostpolicy.dll from [*path*\win-x86\]
I've seen some posts about changing the runtime identifiers so I've set mine to win7-x86;win10-x64
, but that didn't do anything for me .我看过一些关于更改运行时标识符的帖子,所以我将我的设置为
win7-x86;win10-x64
,但这对我没有任何作用。 The win7-x86
is there because it's crucial to my project that the output is 32 bit, otherwise one of the assemblies I'm using won't work at all. win7-x86
之所以存在,是因为输出为 32 位对我的项目至关重要,否则我正在使用的其中一个程序集将根本无法工作。 Right now I'm letting the project compile as a DLL so I can start via the CMD and get some more detailed error messages.现在我让项目编译为 DLL,这样我就可以通过 CMD 启动并获得一些更详细的错误消息。
Here's some more info out of my .csproj:这是我的 .csproj 中的更多信息:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifiers>win7-x86;win10-x64</RuntimeIdentifiers>
<Platforms>x86</Platforms>
<OutputType>library</OutputType>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
And out of my .pubxml:从我的 .pubxml 中:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>x86</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<publishUrl>bin\Release\netcoreapp3.1\x86\publish\</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<SelfContained>true</SelfContained>
<_IsPortable>false</_IsPortable>
<PublishSingleFile>False</PublishSingleFile>
<PublishTrimmed>False</PublishTrimmed>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup>
</Project>
My runtimeconfig looks like this atm:我的 runtimeconfig 看起来像这样的 atm:
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "3.1.0"
}
],
"configProperties": {
"System.GC.Server": true
}
}
}
While it may not be a particularly nice solution, I got it fixed by just creating a new project with .Net Core 3.1 and importing all the same files.虽然它可能不是一个特别好的解决方案,但我只是通过使用 .Net Core 3.1 创建一个新项目并导入所有相同的文件来解决它。 Made some slight changes to the Startup.cs and Program.cs from the template to fit my needs and now it's working again.
对模板中的 Startup.cs 和 Program.cs 进行了一些细微更改以满足我的需要,现在它又可以正常工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.