Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The library 'hostpolicy.dll' required to execute the application

Tags:

c#

.net-core

After adding log4net, I end up with the following error message in publication via the dotnet command (IIS giving a 500 error).

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'MonPath'

Framework : .Net CoreApp 1.1

In Debug mode via VS2017, the application is running.

In my .csproj :

PackageReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="1.1.2" PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" TargetFramework netcoreapp1.1

I have found this solution for project.json but how to apply it to .csproj?

"compilationOptions": { "emitEntryPoint": true }

like image 895
Emeline Avatar asked Jan 29 '23 23:01

Emeline


1 Answers

Just had a similar issue with unit tests unable to be discovered or executed in VS2015. And getting the same error as above if I run the command in a CMD Prompt.

Could not find a solution on the internet a spent a day to find that I needed to place the following in the project.json file

"runtimeOptions": {
  "framework": {
    "name": "Microsoft.NETCore.App",
    "version": "1.0.0"
  }
},

This results the {app}.runtimeconfig.json file to be created in the Debug directory of the build for the app.

This all came about because I installed DotNetCore 2 Preview.

Placing this here cause it was the most resent and second on the google search, hopefully people that need this will find.

like image 158
David Ahrens Avatar answered Feb 02 '23 10:02

David Ahrens