找不到库hostpolicy.dll [英] The library hostpolicy.dll was not found

查看:1666
本文介绍了找不到库hostpolicy.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的.NET Core项目(控制台应用程序),正在尝试编译和运行。 dotnet构建成功,但是执行 dotnet运行时出现以下错误:

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 run:

λ dotnet run
Project RazorPrecompiler (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in [path].

我的project.json看起来像这样:

My project.json looks like this:

{
  "buildOptions": {
    "warningsAsErrors": true
  },
  "dependencies": {
    "Microsoft.AspNetCore.Razor": "1.0.0",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    }
  },
  "description": "Precompiles Razor views.",
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [ ]
    }
  },
  "version": "1.2.0"
}

什么是 hostpolicy.dll ,为什么会丢失?

What is hostpolicy.dll, and why is it missing?

推荐答案

此错误消息无济于事。 实际问题是缺少的 emitEntryPoint 属性:

This error message is unhelpful. The actual problem is a missing emitEntryPoint property:

  "buildOptions": {
    ...
    "emitEntryPoint": true
  },

添加后,编译器将让您知道任何其他问题(例如缺少的 static void Main()方法)。成功编译项目将产生 dotnet运行可执行的输出。

Once this is added, the compiler will let you know about any other problems (like a missing static void Main() method). Successfully compiling the project will result in an output that dotnet run can execute.

这篇关于找不到库hostpolicy.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆