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

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

问题描述

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

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 run 可以执行的输出.

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天全站免登陆