The library hostpolicy.dll was not found

前端 未结 13 1116
自闭症患者
自闭症患者 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 09:01

    Update for dotnet core 2.0 and beyond: the file appname.runtimeconfig.json (for both debug and release configuration) is needed in the same path as appname.dll.

    It contains:

    {
      "runtimeOptions": {
        "tfm": "netcoreapp2.0",
        "framework": {
          "name": "Microsoft.NETCore.App",
          "version": "2.0.0"
        }
      }
    }
    

    then dotnet.exe exec "path/to/appname.dll" [appargs] works.

    0 讨论(0)
  • 2020-11-30 09:01

    For me the issue was with the version mismatch. I had a different ".Net core SDK" version installed and a different version was specified in .json file.

    Once I modified the version in my .json file the application started working fine.

    0 讨论(0)
  • 2020-11-30 09:02

    I had this same problem with a .NET Core 3.0 WPF app, but I found that my app wouldn't run in Visual Studio 2019 either.

    I discovered on the project properties page (right-click on project > Properties) that the Target framework was set to .NET Core 3.0.

    I'd recently updated VS 2019 which had also installed .NET Core 3.1, so I switched to that in the dropdown, and it worked again.

    (I also had to update my shortcut to point to the netcoreapp3.1 folder instead of the previous netcoreapp3.0 folder.)

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

    Promoting voltrevo's comment as an answer as I believe this should be the most common case of the problem. When you build your solution, sometimes you might get 2 directories with outputs bin and obj. 'Bin' directory has everything that is needed to run dotnet.exe command. Just run from the bin directory and things should be good. :)

    0 讨论(0)
  • 2020-11-30 09:09

    This occurred when a Visual Studio 2019 preview upgrade .Net Core to the latest preview (specifically .Net Core 3.1.100-preview2-014569).

    Reinstalling/repairing .Net Core 3.0.100 solved the problem for me.

    0 讨论(0)
  • 2020-11-30 09:09

    Maybe you didn't want to do a "Console .Net Core" project but a "Console .Net Framework" project. It solves the problem, for me...

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