Asp.Net5

时间:2015-11-22 05:24:44

标签: c# asp.net asp.net-core asp.net-core-mvc dnx

当我尝试使用简单的应用程序时,我收到以下错误 ASP.NET 5 RC1。请帮我解决这个问题。不确定,我在哪里犯了错误:(请帮忙。非常感谢你的帮助。

IISHandler Dependency Error Project.json

{
  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },
  "dependencies": {
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
  },
  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "frameworks": {
    "dnx451": {
      "dependencies": {
        "Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
        "Microsoft.AspNet.Mvc": "6.0.0-rc1-final"      
      }
    },
    "dnxcore50": {
      "dependencies": {  }
     }
  },
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "version": "1.0.0-*",
  "webroot": "wwwroot"
}

Startup.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Framework.DependencyInjection;

namespace MVA5
{
    public class Startup
    {
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(Microsoft.Extensions.DependencyInjection.IServiceCollection services)
        {
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app)
        {
            // Add the platform handler to the request pipeline.
            app.UseIISPlatformHandler();

            app.UseMvcWithDefaultRoute();

            //app.Run(async (context) =>
            //{ 
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
    }
}

DNVM列表

dnvm list

2 个答案:

答案 0 :(得分:4)

您的project.jsondnx451dnxcore50中列出了2个目标框架(TFM或目标框架标记)。因此,当您进行构建时,它会为这两个框架构建。

现在,由于"Microsoft.AspNet.Mvc"的依赖关系仅作为dnx451的一部分列出,因此在为dnxcore50构建时,构建失败(我同意错误列表可能是其不是很清楚)。

尝试将"Microsoft.AspNet.Mvc.Core""Microsoft.AspNet.Mvc"依赖项移动到两个TFM共有的dependencies节点,然后进行构建。

答案 1 :(得分:1)

确保使用1.0.0-rc1-final运行时。

将该类型转换为控制台:catch( EntityExistsException | PersistenceException eeEx) 如果不使用1.0.0-rc1-final运行时,请键入console:dnvm upgrade。