.Net Core can't load hostpolicy.dll (HRESULT: 0x800700C1)

1

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
    }
  }
}
c#
asp.net-core
.net-core
asked on Stack Overflow Jan 6, 2020 by Marormur • edited Jan 6, 2020 by Marormur

1 Answer

1

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.

answered on Stack Overflow Jan 7, 2020 by Marormur

User contributions licensed under CC BY-SA 3.0