将.NET Core控制台应用程序部署到Azure WebJobs时加载hostpolicy.dll时出错 [英] Error loading hostpolicy.dll while deploying .NET Core console app to Azure WebJobs

查看:541
本文介绍了将.NET Core控制台应用程序部署到Azure WebJobs时加载hostpolicy.dll时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已遵循此教程将.NET Core控制台应用程序部署到Azure Web Service WebJob。

I have followed this tutorial to deploy a .NET Core console application to an Azure Web Service WebJob.

我的应用程序在本地运行时没有任何问题(dotnet 1.0。 0-preview2-003131 ),但是当我尝试从Azure控制台运行它时,出现以下错误:

My app is running locally without any issue (with dotnet 1.0.0-preview2-003131) but when I try to run it from Azure console I have the following error :

无法从中加载dll [D:\local\VirtualDirectory0\site\wwwroot\app_data\jobs\triggered\PopcornExportWebJob\hostpolicy.dll],HRESULT:0x800700C1

从[D:\local\VirtualDirectory0\site\wwwroot\app_data\jobs\已触发\PopcornExportWebJob]加载所需的库hostpolicy.dll时发生错误

An error occurred while loading required library hostpolicy.dll from [D:\local\VirtualDirectory0\site\wwwroot\app_data\jobs\triggered\PopcornExportWebJob]

Azure dotnet的版本为 1.0.0-rc4-004771 ,并且hostpolicy.dll文件与我在本地使用的文件相同。实际上,当我从Azure下载部署的zip并在本地运行时,它运行良好。

The version of Azure dotnet is 1.0.0-rc4-004771 and the hostpolicy.dll file is the same than I use locally. In fact, when I download the zip of my deploy from Azure and when I run it locally, it is working fine. But it fails on Azure environment.

此外,这是我的project.json:

Also, here is my project.json:

{
      "publishOptions": {
        "include": [
          "run.cmd"
        ]
      },
      "buildOptions": {
        "emitEntryPoint": true,
        "copyToOutput": "appsettings.json"
      },
      "copyright": "bbougot",
      "dependencies": {
        "FubarCoder.RestSharp.Portable.Core": "4.0.7",
        "FubarCoder.RestSharp.Portable.HttpClient": "4.0.7",
        "Microsoft.ApplicationInsights.AspNetCore": "2.0.0",
        "Microsoft.Extensions.Configuration": "1.1.0",
        "Microsoft.Extensions.Configuration.Json": "1.1.0",
        "Microsoft.Extensions.DependencyInjection": "1.1.0",
        "Microsoft.Extensions.Logging": "1.1.0",
        "Microsoft.Extensions.Logging.Console": "1.1.0",
        "Microsoft.NETCore.App": "1.1.0",
        "MongoDB.Driver": "2.4.2",
        "StructureMap.Microsoft.DependencyInjection": "1.3.0"
      },
      "description": "Popcorn Api Exporter",
      "frameworks": {
        "netcoreapp1.1": {
          "imports": [
            "portable-net45+win8"
          ]
        }
      },
      "runtimes": {
        "win10-x64": {}
      },
      "scripts": {
        "postpublish": [ "7za.exe a -tzip PopcornExport.zip .\\bin\\Release\\PublishOutput\\*", 
                         ".\\WAWSDeploy.exe .\\PopcornExport.zip .\\popcornexport.PublishSettings /t app_data\\jobs\\triggered\\PopcornExportWebJob /v /d" ]
      },
      "title": "PopcornExport",
      "version": "1.0.0-*"
    }

我必须添加节点运行时间(win10-x64,否则该应用程序无法在本地运行)。但是,Azure Web服务正在Windows Server 2012上运行。这可能是一个问题吗?

I had to add the node runtimes (win10-x64 otherwise the app can't run locally). But, the Azure Web Service is running on Windows Server 2012. May it be an issue?

我错过了什么?

推荐答案

好的,我已经解决了。

如果要将dotnet核心应用程序部署到Azure Web服务,如果您以32位平台模式运行应用程序,请包含运行时 win7-x86

If you want to deploy a dotnet core app to Azure Web Service, include the runtime "win7-x86" if you are running your app in 32-Bit platform mode.

对于Visual Studio 2015解决方案中,您的project.json应该包括:

For a Visual Studio 2015 solution, your project.json should include :

  "runtimes": {
    "win10-x64": {},
    "win7-x86": {} //IMPORTANT FOR AZURE DEPLOY
  },

或者如果您已经迁移到Visual Studio 2017,则您的.csproj应该将其包括在PropertyGroup中:

Or if you have already migrated to Visual Studio 2017, your .csproj should include this in PropertyGroup:

<RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers>

此外,您的发布个人资料应包括以下内容:

Also, your publish profile should include the same thing:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishProtocol>FileSystem</PublishProtocol>
    <Configuration>Release</Configuration>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <PublishDir>bin\Release\PublishOutput</PublishDir>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier> // IMPORTANT
  </PropertyGroup>
</Project>

这篇关于将.NET Core控制台应用程序部署到Azure WebJobs时加载hostpolicy.dll时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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