4
votes

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 }

5

5 Answers

4
votes

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.

2
votes

I got this error trying to run the .exe from the path:

[myProjectPath]\obj\Debug\netcoreapp3.1

Instead of the path:

[myProjectPath]\bin\Debug\netcoreapp3.1

Just in case somebody else is making the same, dopey mistake.

2
votes

for my .net Core 3.1 app in the 'Release' folder there were some files missing, like

  • '<proj_name>.deps.json'
  • '<proj_name>.runtimeconfig.json'

and some other. Well, it happened because I added one console project as a dependency to another console project. And for the dependent project, the files were missing. This caused the exception. The files are required for 'framework-dependent' applications otherwise it will be run as 'self-contained' and will search for 'hostpolicy.dll' in 'C:\Program Files\dotnet' folder, that is not there because of whatever reason. enter image description here

0
votes

I seems like a .net core version issue. I ran into the same on my production server after my VS project was automatically upgraded to .NET Core 1.1.2.

I simply installed the 1.1.2 .net core runtime from here on my production server: https://www.microsoft.com/net/download/core#/runtime

0
votes

For the latest csproj format (vs 2017), you need to add RuntimeIdentifier element in the csproj file:

<RuntimeIdentifiers>win10-x64;osx.10.11-x64;ubuntu.16.04-x64</RuntimeIdentifiers>

or

<RuntimeIdentifier>win7-x86</RuntimeIdentifier>

BTW, you may need to restore nuget package to avoid the assert error in project.assets.json ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json