服务结构上托管的ASP.Net核心项目无法启动

标签 asp.net asp.net-core asp.net-core-mvc azure-service-fabric

我们尝试在Service Fabric上托管一个ASP.Net核心MVC RC1 DNX项目。部署工作正常,但项目尚未启动。根据我们的日志,似乎服务结构无法找到启动类并创建实例。我们下载了一个可以正常运行的演示项目,但无法启动并运行我们的项目。我们看不到任何有用的日志信息。不在事件日志,服务结构日志流或Visual Studio调试提示中。我们可以做些什么来启用更多调试信息。我们的配置或项目设置可能出什么问题?这是我们项目的关键部分:

ServiceManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="WebPkg"
                 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="WebType" >
      <Extensions>
        <Extension Name="__GeneratedServiceType__">
          <GeneratedNames xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
            <DefaultService Name="WebTypeService" />
            <ServiceEndpoint Name="WebTypeEndpoint" />
          </GeneratedNames>
        </Extension>
      </Extensions>
    </StatelessServiceType>
  </ServiceTypes>

  <CodePackage Name="C" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>approot\runtimes\dnx-clr-win-x64.1.0.0-rc1-update2\bin\dnx.exe</Program>
        <Arguments>--appbase approot\src\Sportflash.Web Microsoft.Dnx.ApplicationHost Microsoft.ServiceFabric.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel</Arguments>
        <WorkingFolder>CodePackage</WorkingFolder>
        <ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048" />
      </ExeHost>
    </EntryPoint>
  </CodePackage>

  <Resources>
    <Endpoints>
      <Endpoint Protocol="http" Name="WebTypeEndpoint" Type="Input" Port="5000" />
    </Endpoints>
  </Resources>
</ServiceManifest>

project.json:
{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "EntityFramework": "6.1.3",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Twitter": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.ServiceFabric.AspNet.Hosting": "1.0.0-rc1",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
    "Sportflash.Web.Core": "1.0.0-*",
    "Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
    "angular-signalr-hub.TypeScript.DefinitelyTyped": "0.6.7",
    "Microsoft.AspNet.Http.Extensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Globalization.CultureInfoCache": "1.0.0-rc1-final",
    "Microsoft.Extensions.Localization.Abstractions": "1.0.0-rc1-final",
    "Microsoft.AspNet.Localization": "1.0.0-rc1-final",
    "Microsoft.Extensions.Localization": "1.0.0-rc1-final",    
    "jquery.TypeScript.DefinitelyTyped": "2.8.8",
    "signalr.TypeScript.DefinitelyTyped": "0.2.0",
    "Newtonsoft.Json": "8.0.3",
    "Microsoft.CodeAnalysis": "1.1.0-rc1-20151109-01"
  },

  "userSecretsId": "aspnet5-Sportflash.Web-f067f2f7-086e-4a52-88ea-a7317d1b11e8",

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "gen": "Microsoft.Extensions.CodeGeneration"
  },

  "frameworks": {
    "dnx451": {
      "dependencies": {
      }
    }
  },
  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components",
    "PackageRoot"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "PackageRoot",    
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "postrestore": [ "npm install", "bower install" ],
    "prepublish": [ "npm install", "bower install" ]
  }
}

Startup.cs:
public class Startup
{
    public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}

最佳答案

我建议在GitHub上探索这个例子。

此示例演示如何在无状态/有状态服务的通信监听器中使用ASP.NET Core。

此示例已更新为使用dotnet cli。

有2个不同的分支dnxdotnetclidnx分支可以在Visual Studio中使用。

关于服务结构上托管的ASP.Net核心项目无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36999026/

相关文章:

c# - 控件在 Chrome 中不会灰显,但在 IE 中会灰显

c# - 从 html 单选按钮获取值 - 在 aspx-c#

asp.net - Windows Server 2008 R2 + IIS 7.5 + ASP.NET 4.0 = HTTP 错误 500.0

c# - .Net Core 中的 DbContextTransaction 在哪里

javascript - 如何使用 AXIOS Get 发送日期?

c# - 如何根据提供的数据将数据显示到gridview中?

c# - 在 ASP.NET Core 中使用 ADO.NET 作为数据访问层

c# - 错误无法使用 .Net Core 3.1 在 Ubuntu 上加载文件或程序集 Tesseract

c# - ASP.Net-Core 中的自定义身份验证

c# - Identity Server 4/nativescript 挂起