The library hostpolicy.dll was not found

前端 未结 13 1114
自闭症患者
自闭症患者 2020-11-30 08:28

I have a simple .NET Core project (console app) that I\'m trying to compile and run. dotnet build succeeds, but I get the following error when I do dotnet

相关标签:
13条回答
  • 2020-11-30 08:48

    If I'm not mistaken, one scenario when you can hit the issue is this: You have an integration project that references another application project (not library). In this case, dependentProject.runtimeconfig.json won't be copied to your integration project's output folder and you won't be able to run dependentProject.exe binary because it will throw The library hostpolicy.dll was not found..

    There is a Github issue for this and a workaround.

    0 讨论(0)
  • 2020-11-30 08:50

    I'm not sure why but I ran in to the problem when executing the .exe file in my \bin folder while the .exe in my \obj folder works fine.

    0 讨论(0)
  • 2020-11-30 08:55

    I am having this problem in Dotnet Core 3.1 Console application.

    If you are publishing your application, make sure that your target runtime set to the specific runtime that you had installed in your target machine.

    If you set to portable it will pick whatever runtime that it feels comfortable (which you might not have it installed)

    0 讨论(0)
  • 2020-11-30 08:58

    In my case it was because I was publishing a self-contained application for the wrong target. My intent was to run on alpine linux, but I was building for libc when I should have been building for musl.

    The failing package was built using:

    dotnet publish --self-contained true --runtime linux-x64 --framework netcoreapp2.1 --output /app
    

    Changing the RID:

    dotnet publish --self-contained true --runtime linux-musl-x64 --framework netcoreapp2.1 --output /app
    

    produced a functional package. Notice the RID changed from linux-x64 to linux-musl-x64. If I had read the .NET Core RID Catalog page this could have been avoided.

    0 讨论(0)
  • 2020-11-30 08:59

    For me it was a stupid mistake: I started a wrong file.

    0 讨论(0)
  • 2020-11-30 08:59

    For me with ASP.NET Core 2.0 on Azure, it was the appname.deps.json that did the trick. You need to copy it from your build directory to Azure.

    0 讨论(0)
提交回复
热议问题