2016-10-02 33 views
1

我正在使用asp.net核心創建和角色2應用程序。我在創建項目時選擇了最新的4.6.1 DotNetFramwork版本。我還添加了Glimpse軟件包版本「2.0.0-beta1」。我在startup.cs文件遇到問題,因爲與IApplicationBuilder接口版本衝突無法使用Glimpse。 IApplicationBuilder包中的歧義

我在startup.cs文件的Configure方法中遇到IApplicationBuilder的歧義錯誤消息。 當我選擇Microsoft.AspNetCore.Builder.IApplicationBuilder包時,我收到一個編譯錯誤,說IApplicationBuilder不包含UseIISPlatformHandler和UseGlimpse的定義。

如果我選擇Microsoft.AspNet.Builder.IApplicationBuilder那麼它抱怨說,IApplicationBuilder不包含定義UseBrowserLink,UseDeveloperExceptionPage,UseExceptionHandler和UseIISPlatformHandler。

我卡住了,不知道如何解決這個問題。需要在我的項目中使用Glimpse。

有人可以幫忙嗎?

下面是我的project.json和startup.cs的副本文件

project.json

{ 
    "dependencies": { 
    "Microsoft.NETCore.App": { 
     "version": "1.0.1", 
     "type": "platform" 
    }, 
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0", 
    "Microsoft.AspNetCore.Diagnostics": "1.0.0", 
    "Microsoft.AspNetCore.Mvc": "1.0.1", 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.0.0-preview2-final", 
     "type": "build" 
    }, 
    "Microsoft.AspNetCore.Routing": "1.0.1", 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", 
    "Microsoft.AspNetCore.StaticFiles": "1.0.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0", 
    "Microsoft.Extensions.Logging": "1.0.0", 
    "Microsoft.Extensions.Logging.Console": "1.0.0", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0", 
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", 
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", 
    "Glimpse": "2.0.0-beta1" 
    }, 

    "tools": { 
    "BundlerMinifier.Core": "2.0.238", 
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" 
    }, 

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

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

    "runtimeOptions": { 
    "configProperties": { 
     "System.GC.Server": true 
    } 
    }, 

    "publishOptions": { 
    "include": [ 
     "wwwroot", 
     "**/*.cshtml", 
     "appsettings.json", 
     "web.config" 
    ] 
    }, 

    "scripts": { 
    "prepublish": [ "bower install", "dotnet bundle" ], 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    } 
} 

startup.cs

using Glimpse; 
using Microsoft.AspNet.Builder; 
using Microsoft.AspNet.Hosting; 
using Microsoft.AspNetCore.Builder; 
using Microsoft.Extensions.Configuration; 
using Microsoft.Extensions.DependencyInjection; 
using Microsoft.Extensions.Logging; 


namespace AspNetCoreAngular2Demo 
{ 
    public class Startup 
    { 
     // Entry point for the application. 
     public static void Main(string[] args) => WebApplication.Run<Startup>(args); 


     public Startup(IHostingEnvironment env) 
     { 
      // Set up configuration sources. 
      var builder = new ConfigurationBuilder() 
       .AddJsonFile("appsettings.json") 
       .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); 

      builder.AddEnvironmentVariables(); 
      Configuration = builder.Build(); 
     } 

     public IConfigurationRoot Configuration { get; set; } 

     // This method gets called by the runtime. Use this method to add services to the container. 
     public void ConfigureServices(IServiceCollection services) 
     { 
      services.AddGlimpse(); 
      services.AddMvc(); 
     } 

     // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 
     public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, 
           IHostingEnvironment env, 
           ILoggerFactory loggerFactory) 
     { 
      loggerFactory.AddConsole(Configuration.GetSection("Logging")); 
      loggerFactory.AddDebug(); 

      if (env.IsDevelopment()) 
      { 
       app.UseBrowserLink(); 
       app.UseDeveloperExceptionPage(); 
      } 
      else 
      { 
       app.UseExceptionHandler("/Home/Error"); 
      } 

      app.UseIISPlatformHandler(options => 
             options.AuthenticationDescriptions.Clear()); 
      app.UseStaticFiles(); 
      app.UseGlimpse(); 

      app.UseMvc(routes => 
      { 
       routes.MapRoute("default", 
           "{controller=Home}/{action=Index}/{id?}"); 
       routes.MapRoute("spa-fallback", 
           "{*anything}", 
           new { controller = "Home", action = "Index" }); 
       routes.MapWebApiRoute("defaultApi", 
             "api/{controller}/{id?}"); 
      }); 
     } 

    } 
} 
+0

你找到解決這個? – Paul

+0

有同樣的問題,並按照這些說明,它的工作原理:https://github.com/Glimpse/Glimpse.Prototype/issues/123#issuecomment-276980579 –

回答

0

掠影2測試版1支持.NET Core RC1。

嘗試使用掠影2 Beta 2的從https://www.myget.org/gallery/glimpseprototype中的NuGet提要.NET核心RTM支持

+1

我試着添加條目「Glimpse」:「2.0.0-beta2 「在project.json中,並將網址https://www.myget.org/gallery/glimpseprototype添加到Visual Studio 2015編輯器的NugetManager中的設置包源代碼中。它不下載庫並安裝它。任何線索 – Mike