Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have followed the steps here to upgrade from ASP.NET 5 Beta 4 to Beta 5 but am getting an error at runtime when calling application.UseBrowserLink();:

An exception of type 'System.TypeLoadException' occurred in mscorlib.dll but was not handled in user code

Additional information: Could not load type 'Microsoft.AspNet.Builder.IApplicationBuilder' from assembly 'Microsoft.AspNet.Http, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

These are the steps I followed:

  1. Had VS 2015 RC already installed.
  2. From PowerShell run: $env:DNX_FEED="https://www.nuget.org/api/v2"
  3. From PowerShell run: dnvm upgrade
  4. Added a Global.json file (I did not already have one). When I added it, it referred to Beta 5 already:

    {
        "projects": [ "Source", "Tests" ],
        "sdk": {
            "version": "1.0.0-beta5-12103"
        }
    }
    
  5. Updated all packages in project.json to Beta 5. You can see a full version of my project.lock.json file here.

    {
      "dependencies": {
        "Boilerplate.Web.Mvc6": "1.0.2",
        "Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
        "Microsoft.AspNet.Mvc": "6.0.0-beta5",
        "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
        "Microsoft.AspNet.Mvc.Xml": "6.0.0-beta5",
        "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
        "Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
        "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
        "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5",
        "Microsoft.Framework.Configuration.EnvironmentVariables": "1.0.0-beta5",
        "Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
        "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5",
        "Microsoft.Framework.Logging": "1.0.0-beta5",
        "Microsoft.Framework.Logging.Console": "1.0.0-beta5",
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",
        "Newtonsoft.Json": "6.0.6",
        "System.Runtime": "4.0.20-beta-23019"
      }
      "frameworks": {
          "dnx451": {
            "frameworkAssemblies": {
              "System.Net.Http": "4.0.0.0",
              "System.ServiceModel": "4.0.0.0"
            }
          },
          "dnxcore50": {
            "dependencies": {
              "System.Net.Http": "4.0.0-beta-23019"
            }
          }
        }
    }
    
  6. The instructions then go on to say you should run the following commands but I believe VS 2015 RC does this for you dnu restore then dnu build.

UPDATE

It seems to be a problem with browser link, commenting the line out allows the site to work. It may be broken? Need to hunt around the aspnet GitHub issues.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
237 views
Welcome To Ask or Share your Answers For Others

1 Answer

In order to help you migrate from beta4 to beta5, these are the following steps it took me, based on the research/findings.

Environment

  • PowerShell run: $env:DNX_FEED="https://www.nuget.org/api/v2"
  • PowerShell run: dnvm install 1.0.0-beta5
  • PowerShell run: dnvm use 1.0.0-beta5 -p (not sure if its needed however i had to)

Project

  • Open global.json and update sdk to 1.0.0-beta5 should look like this:

    {
        "projects": [ "src", "test" ],
        "sdk": {
            "version": "1.0.0-beta5"
        }
    }
    
  • Open project.json:

    • Updated dependencies versions from beta4 to beta5
    • Change Configuration dependency from:

      "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4"
      

      to

      "Microsoft.Framework.Configuration": "1.0.0-beta5",
      "Microsoft.Framework.Configuration.Json": "1.0.0-beta5"
      
    • Remove Microsoft.VisualStudio.Web.BrowserLink.Loader
    • Rename _GlobalImport.cshtml to _ViewImports.cshtml

Startup.cs changes

  • Change Configuration breaking changes

    • Change namespace from using Microsoft.Framework.ConfigurationModel; to using Microsoft.Framework.Configuration;

    • Change Configuration.GetSubKey to Configuration.GetConfigurationSection

    • Change CTOR to:

      public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
      {           
          // Setup configuration sources.
          var configBuilder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
          .AddJsonFile("config.json")
          .AddEnvironmentVariables();
      
          Configuration = configBuilder.Build();
      }
      
    • Remove app.UseBrowserLink();

Project DNU CMDs

  • Open PowerShell within app root
  • Run dnu restore
  • Run dnu build
  • Closing and reopening VS at this point helps sometimes.

Myself found it quite difficult to upgrade an existing project, couldn't find all steps required all together. Hope it helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...