.Net Core 无法加载 hostpolicy.dll (HRESULT: 0x800700C1)

huangapple go评论100阅读模式
英文:

.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:

  &lt;PropertyGroup&gt;
    &lt;TargetFramework&gt;netcoreapp3.1&lt;/TargetFramework&gt;
    &lt;RuntimeIdentifiers&gt;win7-x86;win10-x64&lt;/RuntimeIdentifiers&gt;
    &lt;Platforms&gt;x86&lt;/Platforms&gt;
    &lt;OutputType&gt;library&lt;/OutputType&gt;
    &lt;TargetLatestRuntimePatch&gt;true&lt;/TargetLatestRuntimePatch&gt;
  &lt;/PropertyGroup&gt;

And out of my .pubxml:

&lt;Project ToolsVersion=&quot;4.0&quot; xmlns=&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot;&gt;
  &lt;PropertyGroup&gt;
    &lt;WebPublishMethod&gt;FileSystem&lt;/WebPublishMethod&gt;
    &lt;PublishProvider&gt;FileSystem&lt;/PublishProvider&gt;
    &lt;LastUsedBuildConfiguration&gt;Release&lt;/LastUsedBuildConfiguration&gt;
    &lt;LastUsedPlatform&gt;x86&lt;/LastUsedPlatform&gt;
    &lt;SiteUrlToLaunchAfterPublish /&gt;
    &lt;LaunchSiteAfterPublish&gt;True&lt;/LaunchSiteAfterPublish&gt;
    &lt;ExcludeApp_Data&gt;False&lt;/ExcludeApp_Data&gt;
    &lt;TargetFramework&gt;netcoreapp3.1&lt;/TargetFramework&gt;
    &lt;RuntimeIdentifier&gt;win-x86&lt;/RuntimeIdentifier&gt;
    &lt;publishUrl&gt;bin\Release\netcoreapp3.1\x86\publish\&lt;/publishUrl&gt;
    &lt;DeleteExistingFiles&gt;True&lt;/DeleteExistingFiles&gt;
    &lt;SelfContained&gt;true&lt;/SelfContained&gt;
    &lt;_IsPortable&gt;false&lt;/_IsPortable&gt;
    &lt;PublishSingleFile&gt;False&lt;/PublishSingleFile&gt;
    &lt;PublishTrimmed&gt;False&lt;/PublishTrimmed&gt;
    &lt;PublishReadyToRun&gt;False&lt;/PublishReadyToRun&gt;
  &lt;/PropertyGroup&gt;
&lt;/Project&gt;

My runtimeconfig looks like this atm:

{
  &quot;runtimeOptions&quot;: {
&quot;tfm&quot;: &quot;netcoreapp3.1&quot;,
&quot;includedFrameworks&quot;: [
  {
    &quot;name&quot;: &quot;Microsoft.NETCore.App&quot;,
    &quot;version&quot;: &quot;3.1.0&quot;
  },
  {
    &quot;name&quot;: &quot;Microsoft.AspNetCore.App&quot;,
    &quot;version&quot;: &quot;3.1.0&quot;
  }
],
&quot;configProperties&quot;: {
  &quot;System.GC.Server&quot;: 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.

huangapple
  • 本文由 发表于 2020年1月6日 16:32:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/59608891.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定