Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF Powershell fails to load hostpolicy.dll when RuntimeIdentifier is win7-x86 #4865

Closed
Suchiman opened this issue Dec 13, 2018 · 4 comments
Labels
Milestone

Comments

@Suchiman
Copy link

@Suchiman Suchiman commented Dec 13, 2018

With a csproj looking like

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
  <PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
  </ItemGroup>

Trying to issue following command on the package Manager console
Scaffold-DbContext "Server=..." Microsoft.EntityFrameworkCore.SqlServer -OutputDir Database -Force
will result in this error being generated:

Failed to load the dll from [Project\bin\Debug\netcoreapp2.2\win7-x86\hostpolicy.dll], HRESULT: 0x800700C1
An error occurred while loading required library hostpolicy.dll from [Project\bin\Debug\netcoreapp2.2\win7-x86\]

Changing

    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>

to

    <RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers>

fixes this but has dotnet/cli#10474 as a side effect

@elinor-fung

This comment has been minimized.

Copy link
Member

@elinor-fung elinor-fung commented Jun 12, 2019

0x800700C1 : ERROR_BAD_EXE_FORMAT
I suspect this is because the Scaffold-DbContext powershell command is running the 64-bit dotnet, so it failing to load the 32-bit hostpolicy. (I think the command just uses whichever dotnet is on the path).

@Suchiman could you try running that command in the package manager console with -Verbose? It should show the actual dotnet.exe command being run, so we can see where it is being run from and if it is indeed the 64-bit dotnet trying to load 32-bit binaries.

@Suchiman

This comment has been minimized.

Copy link
Author

@Suchiman Suchiman commented Jun 12, 2019

Using project 'WebApplication57'.
Using startup project 'WebApplication57'.
Build started...
Build succeeded.
C:\Program Files\dotnet\dotnet.exe exec
 --depsfile %USERPROFILE%\Source\Repos\WebApplication57\WebApplication57\bin\Debug\netcoreapp2.2\win7-x86\WebApplication57.deps.json
 --additionalprobingpath %USERPROFILE%\.nuget\packages
 --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder"
 --runtimeconfig %USERPROFILE%\Source\Repos\WebApplication57\WebApplication57\bin\Debug\netcoreapp2.2\win7-x86\WebApplication57.runtimeconfig.json
 %USERPROFILE%\.nuget\packages\microsoft.entityframeworkcore.tools\2.2.0\tools\netcoreapp2.0\any\ef.dll
 dbcontext scaffold Server=... Microsoft.EntityFrameworkCore.SqlServer
 --json
 --output-dir Database
 --force
 --verbose
 --no-color
 --prefix-output
 --assembly %USERPROFILE%\Source\Repos\WebApplication57\WebApplication57\bin\Debug\netcoreapp2.2\win7-x86\WebApplication57.dll
 --startup-assembly %USERPROFILE%\Source\Repos\WebApplication57\WebApplication57\bin\Debug\netcoreapp2.2\win7-x86\WebApplication57.dll
 --project-dir %USERPROFILE%\Source\Repos\WebApplication57\WebApplication57\
 --language C#
 --working-dir %USERPROFILE%\Source\Repos\WebApplication57
 --root-namespace WebApplication57
Failed to load the dll from [%USERPROFILE%\Source\Repos\WebApplication57\WebApplication57\bin\Debug\netcoreapp2.2\win7-x86\hostpolicy.dll], HRESULT: 0x800700C1
An error occurred while loading required library hostpolicy.dll from [%USERPROFILE%\Source\Repos\WebApplication57\WebApplication57\bin\Debug\netcoreapp2.2\win7-x86\]
@jeffschwMSFT

This comment has been minimized.

Copy link
Member

@jeffschwMSFT jeffschwMSFT commented Jun 12, 2019

@Suchiman

This comment has been minimized.

Copy link
Author

@Suchiman Suchiman commented Jun 12, 2019

This issue has been ignored for over half a year so my memory is faded but AFAIR i was using a publish profile in VS, building the .sln file and it was barking at me for only specifying the RuntimeIdentifier in the publish xml and not specifying it in the .csproj as well.

Nontheless, letting users run into a wall without at least giving a plausible error message doesn't seem like the best approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.