简体   繁体   English

执行应用程序所需的库“hostpolicy.dll”

[英]The library 'hostpolicy.dll' required to execute the application

After adding log4net, I end up with the following error message in publication via the dotnet command (IIS giving a 500 error).添加 log4net 后,我最终通过 dotnet 命令发布了以下错误消息(IIS 给出 500 错误)。

A fatal error was encountered.遇到致命错误。 The library 'hostpolicy.dll' required to execute the application was not found in 'MonPath'在“MonPath”中找不到执行应用程序所需的库“hostpolicy.dll”

Framework: .Net CoreApp 1.1框架:.Net CoreApp 1.1

In Debug mode via VS2017, the application is running.在通过 VS2017 的调试模式下,应用程序正在运行。

In my.csproj:在我的.csproj 中:

PackageReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="1.1.2" PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" TargetFramework netcoreapp1.1 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?我已经为 project.json 找到了这个解决方案,但是如何将它应用到 .csproj?

"compilationOptions": { "emitEntryPoint": true } “compilationOptions”:{“emitEntryPoint”:真}

Just had a similar issue with unit tests unable to be discovered or executed in VS2015.刚遇到类似的问题,无法在 VS2015 中发现或执行单元测试。 And getting the same error as above if I run the command in a CMD Prompt.如果我在 CMD 提示符下运行命令,则会出现与上述相同的错误。

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花了一天时间在互联网上找不到解决方案,发现我需要将以下内容放在 project.json 文件中

"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.这会导致在应用构建的调试目录中创建 {app}.runtimeconfig.json 文件。

This all came about because I installed DotNetCore 2 Preview.这一切都是因为我安装了 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.把它放在这里是因为它是谷歌搜索中最反感和第二的,希望需要它的人能找到。

I got this error trying to run the.exe from the path:我在尝试从路径运行 the.exe 时遇到此错误:

[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.以防其他人犯同样的愚蠢错误。

for my .net Core 3.1 app in the 'Release' folder there were some files missing, like对于我在“发布”文件夹中的 .net Core 3.1 应用程序,缺少一些文件,例如

  • '<proj_name>.deps.json' '<proj_name>.deps.json'
  • '<proj_name>.runtimeconfig.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. “依赖于框架”的应用程序需要这些文件,否则它将作为“自包含”运行,并将在“C:\Program Files\dotnet”文件夹中搜索“hostpolicy.dll”,但由于任何原因不存在原因。 在此处输入图像描述

I seems like a .net core version issue.我似乎是 .net 核心版本问题。 I ran into the same on my production server after my VS project was automatically upgraded to .NET Core 1.1.2.在我的 VS 项目自动升级到 .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我只是从这里在我的生产服务器上安装了 1.1.2 .net 核心运行时: https ://www.microsoft.com/net/download/core#/runtime

For the latest csproj format (vs 2017), you need to add RuntimeIdentifier element in the csproj file:对于最新的 csproj 格式(vs 2017),您需要在 csproj 文件中添加 RuntimeIdentifier 元素:

<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顺便说一句,您可能需要恢复 nuget 包以避免 project.assets.json 中的断言错误ASP.NET Core Application (.NET Framework) for Windows x64 only project.assets.json 中的错误

This is an old question that seems to have multiple possible answers, particularly if experienced during an Azure deployment.这是一个似乎有多种可能答案的老问题,尤其是在 Azure 部署期间遇到的问题。 In my case, I ran into this when trying to run an ASP.NET Core 2.1 app deployed to IIS on-premise.就我而言,我在尝试运行部署到本地 IIS 的 ASP.NET Core 2.1 应用程序时遇到了这个问题。

For me this was caused by trying to run a self-contained app - an app that output to EXE instead of a DLL, and was not runtime-dependent - using a dotnet command.对我来说,这是由于尝试运行一个独立的应用程序引起的——一个输出到 EXE 而不是 DLL 的应用程序,并且不依赖于运行时——使用dotnet命令。 I didn't need to use the dotnet CLI to execute what was already an EXE;我不需要使用 dotnet CLI 来执行已经是 EXE 的东西; I just had to execute it directly.我只需要直接执行它。 However this error message was completely misleading in that case.但是,在那种情况下,此错误消息完全具有误导性。

I ran into this problem when trying to execute the application directly on the server to troubleshoot why it appeared not to start in IIS, which on an unrelated note, was caused by not having the proper version of the ASP.NET Core Hosting Bundle installed.当我尝试直接在服务器上执行应用程序以解决为什么它似乎无法在 IIS 中启动时遇到了这个问题,这是由于没有安装正确版本的 ASP.NET Core Hosting Bundle 引起的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 消息:遇到致命错误。 在“C:\Program Files\dotnet”中找不到执行应用程序所需的库“hostpolicy.dll” - Message: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet' 加载所需库 hostpolicy.dll 时出错 - An error occurred while loading required library hostpolicy.dll 将 .NET Core 控制台应用程序部署到 Azure WebJobs 时加载 hostpolicy.dll 时出错 - Error loading hostpolicy.dll while deploying .NET Core console app to Azure WebJobs .Net Core 无法加载 hostpolicy.dll (HRESULT: 0x800700C1) - .Net Core can't load hostpolicy.dll (HRESULT: 0x800700C1) Azure .net6.0 上的函数无法在本地运行 hostpolicy.dll 错误 - Azure Functions on .net6.0 fail to run locally with hostpolicy.dll error 将EXE和所需的DLL嵌入.NET应用程序中并在运行时执行 - Embed EXE and required DLL in .NET application and execute at runtime DLL引用到应用程序但不是类库 - DLL References into Application but not Class Library 控制台应用程序 DLL 和 Class 库 DLL 之间的区别 - Difference between Console Application DLL and Class Library DLL 在类库应用程序上找不到security.dll库 - Unable to find security.dll library on class library application 加载程序集(dll库)时执行初始化函数,卸载程序集时执行清理函数 - Execute init function when assembly(dll library) gets loaded, execute clean up function when it gets unloaded
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM