c# - 在 Service Fabric 中调试 .NET Core RC2 Web 应用程序时出现错误消息

标签 c# asp.net-core azure-service-fabric

我终于设法将 .NET Core RC2 Web 应用程序上传到 Service Fabric。但是一旦部署,我就会在 Visual Studio 中收到以下错误消息:

Error message

在 Service Fabric Explorer 中,我在 Web 应用程序的分区中收到以下错误:

Error message Service Fabric

我的 ServiceManifest.xml 如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="WebApplicationPkg"
             Version="1.0.0"
             xmlns="http://schemas.microsoft.com/2011/01/fabric"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ServiceTypes>
    <StatelessServiceType ServiceTypeName="WebApplicationType" />
  </ServiceTypes>

  <CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>WebApplication.exe</Program>
      </ExeHost>
    </EntryPoint>
  </CodePackage>
  <ConfigPackage Name="Config" Version="1.0.0" />

  <Resources>
    <Endpoints>
      <Endpoint Name="ServiceEndpoint" />
    </Endpoints>
  </Resources>
</ServiceManifest>

还有我的 project.json:

{
  "dependencies": {
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
    "NETStandard.Library": "1.5.0-rc2-24027"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "runtimes": {
    "win10-x64": { }
  },

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

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
  }
}

我的 Progam.cs:

public class Program
{
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseStartup<Startup>()
            .Build();

        host.Run();
    }
}

谁能看出我做错了什么?这个错误来自哪里? 当我在本地运行应用程序时,一切正常。将其部署到 Service Fabric 后,我立即收到这些错误。

谢谢!

最佳答案

我之前遇到过类似的问题。我还没有找出具体问题。我怀疑这是因为该服务未将自身注册到服务结构运行时,导致健康分区的数量(对于特定服务)低于指定值(应用程序 list 中的 InstanceCount)。

我是根据SDK中提供的OwinCommunicationListener创建通信监听器解决的。我的实现与您在 Hosting repo by weidazhao (David) 中找到的非常相似.我推荐它,因为它似乎与官方 SDK 中的内容非常接近。

关于c# - 在 Service Fabric 中调试 .NET Core RC2 Web 应用程序时出现错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37413596/

相关文章:

c# - 替换 css 中的大小参数

c# - 对预检请求的响应未通过访问控制检查 : The value of the 'Access-Control-Allow-Credentials' header in the response is ''

azure - Service Fabric - 集群中的 Web api,唯一的工作是提供来自可靠集合的数据

c# - 嵌入 Perl 解释器

C# 抽象结构

c# - 在 ASP.NET Web.config 中指定 uploadReadAheadSize

azure - IFeatureManager 单元测试

c# - EF Core 预加载返回 null

azure - Azure API 应用程序和 Azure Service Fabric 之间有什么区别?

visual-studio-2015 - 向现有服务结构应用程序添加新服务