英文:
.Net Core can't load hostpolicy.dll (HRESULT: 0x800700C1)
问题
我正在将我的项目从.Net Core 2.2升级到3.1的过程中遇到了一些问题。首先,通过命令行启动时,我收到了一个错误消息,说找不到输出文件夹中的hostpolicy.dll。为了解决这个问题,我安装了Microsoft.NETCore.DotNetHostPolicy
,但现在我收到了这个错误消息:
无法从[*path*\win-x86\hostpolicy.dll]加载dll,HRESULT: 0x800700C1
从[*path*\win-x86\]加载所需库hostpolicy.dll时发生错误
我看到一些帖子提到了更改运行时标识符,所以我将我的设置更改为win7-x86;win10-x64
,但对我没有任何帮助。win7-x86
存在的原因是因为对于我的项目来说,输出为32位至关重要,否则我使用的某些程序集将根本无法工作。目前,我让项目编译为DLL,这样我可以通过CMD启动并获得更详细的错误消息。
这是我的.csproj中的一些更多信息:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifiers>win7-x86;win10-x64</RuntimeIdentifiers>
<Platforms>x86</Platforms>
<OutputType>library</OutputType>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
以及我的.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>
目前我的runtimeconfig如下:
{
"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
}
}
}
英文:
I'm in the middle of upgrading my project from .Net Core 2.2 to 3.1, but I've ran into some issues. 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. To fix that I installed Microsoft.NETCore.DotNetHostPolicy
, but now I'm getting this error message:
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 . 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. 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.
Here's some more info out of my .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:
<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:
{
"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
}
}
}
答案1
得分: 1
我用 .Net Core 3.1 创建了一个新项目,并导入了相同的文件,稍微修改了 Startup.cs 和 Program.cs 以满足我的需求,现在它又可以正常工作了。
英文:
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. Made some slight changes to the Startup.cs and Program.cs from the template to fit my needs and now it’s working again.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论