问题描述
我已按照步骤 此处 从 ASP.NET 5 Beta 4 升级到 Beta 5,但在调用 application.UseBrowserLink(); 时在运行时出错;
:
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();
:
System.TypeLoadException"类型的异常发生在mscorlib.dll 但未在用户代码中处理
An exception of type 'System.TypeLoadException' occurred in mscorlib.dll but was not handled in user code
附加信息:无法加载类型程序集中的Microsoft.AspNet.Builder.IApplicationBuilder"'Microsoft.AspNet.Http,版本=1.0.0.0,文化=中性,PublicKeyToken=null'.
Additional information: Could not load type 'Microsoft.AspNet.Builder.IApplicationBuilder' from assembly 'Microsoft.AspNet.Http, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
这些是我遵循的步骤:
- 已经安装了 VS 2015 RC.
- 从 PowerShell 运行:
$env:DNX_FEED="https://www.nuget.org/api/v2"
- 从 PowerShell 运行:
dnvm 升级
添加了一个 Global.json 文件(我还没有).当我添加它时,它已经提到了 Beta 5:
- Had VS 2015 RC already installed.
- From PowerShell run:
$env:DNX_FEED="https://www.nuget.org/api/v2"
- From PowerShell run:
dnvm upgrade
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"
}
}
将 project.json 中的所有包更新到 Beta 5.您可以看到我的 project.lock.json 文件的完整版本 这里.
{
"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"
}
}
}
}
dnu restore
然后 dnu build
.更新
这似乎是浏览器链接的问题,注释掉该行可以使网站正常工作.可能坏了?需要寻找 aspnet GitHub 问题.
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.
推荐答案
为了帮助您从 beta4 迁移到 beta5,这些是我根据研究/发现采取的以下步骤.
In order to help you migrate from beta4 to beta5, these are the following steps it took me, based on the research/findings.
- PowerShell 运行:
$env:DNX_FEED="https://www.nuget.org/api/v2"
- PowerShell 运行:
dnvm install 1.0.0-beta5
- PowerShell 运行:
dnvm 使用 1.0.0-beta5 -p
(不确定是否需要,但我必须这样做)
打开 global.json 并将 sdk 更新为 1.0.0-beta5 应该如下所示:
Open global.json and update sdk to 1.0.0-beta5 should look like this:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta5"
}
}
打开project.json:
Open project.json:
- 将依赖项版本从 beta4 更新到 beta5
从以下位置更改配置依赖项:
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4"
到
"Microsoft.Framework.Configuration": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5"
Microsoft.VisualStudio.Web.BrowserLink.Loader
_GlobalImport.cshtml
重命名为 _ViewImports.cshtml
Microsoft.VisualStudio.Web.BrowserLink.Loader
_GlobalImport.cshtml
to _ViewImports.cshtml
更改配置的重大更改
Change Configuration breaking changes
将命名空间从
using Microsoft.Framework.ConfigurationModel;
更改为using Microsoft.Framework.Configuration;
将 Configuration.GetSubKey
更改为 Configuration.GetConfigurationSection
将 CTOR 更改为:
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();
}
app.UseBrowserLink();
- 在应用根目录 中打开 PowerShell
- 运行
dnu restore
- 运行
dnu 构建
- 此时关闭和重新打开 VS 有时会有所帮助.
我自己发现升级现有项目非常困难,无法找到所需的所有步骤.希望对您有所帮助!
Myself found it quite difficult to upgrade an existing project, couldn't find all steps required all together. Hope it helps!
这篇关于从 ASP.NET 5 Beta 4 升级到 Beta 5 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!