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

时间:2016-05-24 12:28:22

标签: 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,我就会遇到这些错误。

谢谢!

1 个答案:

答案 0 :(得分:1)

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

我通过基于SDK中提供的OwinCommunicationListener创建通信侦听器来解决它。我的实现与Hosting repo by weidazhao (David)中的实现非常相似。我建议,因为它似乎足够接近官方SDK中的内容。