我该怎么办时,ASP.NET 5(vNext)不能重定向的绑定? [英] What do I do when ASP.NET 5 (vNext) can't redirect bindings?
问题描述
我刚开始我的脚湿MVC 6.我安装了VS 2015年和默认 ASP.NET 5 preVIEW
MVC Web应用程序
模板一切运行在本地IIS罚款。
我然后试图用 StructureMap
转出默认的DI容器下面的这些说明准确(注意这是一个非常最近的一篇文章)。唯一的一点是我必须要弄清楚的命名空间来导入自己(因为笔者忘了把它们),这就是我在内。
我把 StructureMa pregistration
类和所有相关的类到一个文件,这里是usings。
使用Microsoft.Framework.DependencyInjection;
使用StructureMap;
使用StructureMap.Configuration.DSL.Ex pressions;
我添加了以下usings到 Startup.cs
文件。
使用StructureMap;
使用StructureMap.Graph;
使用的System.Reflection;
和我做了以下编辑到 Startup.cs
文件。
//此方法被运行时调用。使用此方法可以服务于容器中添加。
公共无效ConfigureServices(IServiceCollection服务)
{
//到服务容器添加实体框架服务。
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext< ApplicationDbContext>(选项=>
options.UseSqlServer(配置[数据:DefaultConnection:ConnectionString的])); //到服务容器添加身份服务。
services.AddIdentity< ApplicationUser,IdentityRole>()
.AddEntityFrameworkStores< ApplicationDbContext>()
.AddDefaultTokenProviders(); //配置认证中间件的选项。
//可以如下图所示谷歌,Twitter和其他中间件添加选项。
//欲了解更多信息,请参阅http://go.microsoft.com/fwlink/?LinkID=532715
services.Configure< FacebookAuthenticationOptions>(选项=>
{
options.AppId =配置[认证:Facebook的:的AppId];
options.AppSecret =配置[认证:Facebook的:AppSecret];
}); services.Configure< MicrosoftAccountAuthenticationOptions>(选项=>
{
options.ClientId =配置[验证:MicrosoftAccount:客户端Id];
options.ClientSecret =配置[验证:MicrosoftAccount:ClientSecret];
}); //到服务容器添加MVC服务。
services.AddMvc(); ////取消对以下行添加的Web API服务,这使得它更容易端口的Web API 2控制器。
////你还需要将Microsoft.AspNet.Mvc.WebApiCompatShim包添加到project.json的依存关系部分。
//// services.AddWebApiConventions(); ////注册应用服务。
//services.AddTransient<IEmailSender,AuthMessageSender&GT;();
//services.AddTransient<ISmsSender,AuthMessageSender&GT;(); VAR集装箱=新容器();
container.Configure(X =&GT;
{
x.Scan(扫描=&GT;
{
scanning.Assembly(Assembly.GetExecutingAssembly());
scanning.TheCallingAssembly();
scanning.WithDefaultConventions();
}); //x.AddRegistry<WebsiteRegistry>();
}); //我们的框架扩展点
container.Populate(服务);
}
从字面上看,在的只有的的事情,我已经从默认模板修改是上述code的变化和安装
StructureMap
3.1.6.186。
块引用>using语句燮preSS所有的设计时间编译错误,但是当我建,我让其他几个错误。
错误CS0012类型动作&LT;>'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 32
错误CS0012类型'IDisposable的'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 32
错误CS0012类型Func键&LT;,>'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 59
错误CS0012类型'对象'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 59
错误CS0012类型'类型'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 63
错误CS0012类型防爆pression&LT;>'在未引用的程序集定义。您必须添加一个引用程序集System.Core程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 63
错误CS0012类型'对象'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 63
错误CS0012类型'类型'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 67
错误CS0012类型防爆pression&LT;>'在未引用的程序集定义。您必须添加一个引用程序集System.Core程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 67
错误CS0012类型'对象'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 67
错误CS0012类型'类型'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 89
错误CS0012类型'IDisposable的'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 89
错误CS0411的方法'IContainer.GetInstance(字符串)'的类型参数不能从使用推断。请尝试显式指定类型参数。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 89
错误CS0012类型'IDisposable的'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 107
错误CS0012类型'IDisposable的'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 107
错误CS0012类型'IDisposable的'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 120
错误CS1061'的IContainer'不包含'处置',没有扩展方法'处置'接受型的IContainer'的第一个参数的定义可以找到(是否缺少using指令或程序集引用?)TestDI3 .DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ SERVICES \\ StructureMa pregistration.cs 120
错误CS0012类型动作&LT;>'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ Startup.cs 94
错误CS0012类型'对象'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\的Visual Studio 2015 \\项目\\ TestDI3的\\ src \\ TestDI3 \\ Startup.cs 94
错误CS0012类型'对象'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ Startup.cs 107
错误CS0012类型'IDisposable的'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ Startup.cs 107
错误CS0012类型'对象'在未引用的程序集定义。您必须添加到程序集的引用'mscorlib程序,版本= 2.0.5.0,文化=中性公钥= 7cec85d7bea7798e,重定目标=是。 TestDI3.DNX核心5.0 F:\\用户\\沙德\\文档\\ Visual Studio的2015年\\项目\\ TestDI3的\\ src \\ TestDI3 \\ Startup.cs 107
块引用>该错误表示问题出在哪里 - 我需要一个参考MSCORLIB 2.0.5.0。但我已在项目中引用mscorlib程序4.0.0.0。
在ASP.NET&LT这一点; 5,下一步通常是一些有约束力的重定向添加到
&LT; bindingRedirect&GT;
web.config文件的部分。然而,寻找如何做到这一点的ASP.NET 5之后,我遇到这个答案一>这表明绑定重定向被认为是完全自动。因此,这是一个错误,或者是有没有我的配置,我错过了就是导致这个错误?一些步
配置
DNX 1.0.0-beta5的
.NET框架
86
IIS防爆preSS
块引用>project.json
{
根目录:wwwroot的
userSecretsId:aspnet5-TestDI3-1665343b-5aa5-4d08-8596-a1a536223a19,
版本:1.0.0- *, 依赖:{
EntityFramework.SqlServer:7.0.0-beta5的,
EntityFramework.Commands:7.0.0-beta5的,
Microsoft.AspNet.Mvc:6.0.0-beta5的,
Microsoft.AspNet.Mvc.TagHelpers:6.0.0-beta5的,
Microsoft.AspNet.Authentication.Cookies:1.0.0-beta5的
Microsoft.AspNet.Authentication.Facebook:1.0.0-beta5的
Microsoft.AspNet.Authentication.Google:1.0.0-beta5的
Microsoft.AspNet.Authentication.MicrosoftAccount:1.0.0-beta5的
Microsoft.AspNet.Authentication.Twitter:1.0.0-beta5的
Microsoft.AspNet.Diagnostics:1.0.0-beta5的
Microsoft.AspNet.Diagnostics.Entity:7.0.0-beta5的,
Microsoft.AspNet.Identity.EntityFramework:3.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.Configuration.Abstractions: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的,
structuremap:3.1.6.186
}, 命令:{
网络:Microsoft.AspNet.Hosting --config hosting.ini
EF:EntityFramework.Commands
}, 构架: {
dnx451:{},
dnxcore50:{}
}, 排除:[
wwwroot的
node_modules
bower_components
]
publishExclude:[
node_modules
bower_components
**。xproj
**。用户,
**。vspscc
]
脚本:{
prepublish:故宫安装,亭子安装,大口喝干净,吞掉分钟]
}
}
解决方案由于opiants,这个问题似乎与一个事实,即在
dnxcore50
框架被列入该项目。框架:{
dnx451:{},
dnxcore50:{}
}删除它解决了这一问题。
框架:{
dnx451:{}
}I am just getting my feet wet with MVC 6. I installed VS 2015 and with the default
ASP.NET 5 preview
MVC Web Application
template everything runs fine under local IIS.I then tried to switch out the Default DI container with
StructureMap
following these instructions exactly (note it is a very recent article). The only thing is I had to figure out the namespaces to import myself (since the author neglected to include them) and this is what I included.I put the
StructureMapRegistration
class and all related classes into a single file, and here are the usings.using Microsoft.Framework.DependencyInjection; using StructureMap; using StructureMap.Configuration.DSL.Expressions;
I added the following usings to the
Startup.cs
file.using StructureMap; using StructureMap.Graph; using System.Reflection;
And I made the following edit to the
Startup.cs
file.// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add Entity Framework services to the services container. services.AddEntityFramework() .AddSqlServer() .AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])); // Add Identity services to the services container. services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); // Configure the options for the authentication middleware. // You can add options for Google, Twitter and other middleware as shown below. // For more information see http://go.microsoft.com/fwlink/?LinkID=532715 services.Configure<FacebookAuthenticationOptions>(options => { options.AppId = Configuration["Authentication:Facebook:AppId"]; options.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; }); services.Configure<MicrosoftAccountAuthenticationOptions>(options => { options.ClientId = Configuration["Authentication:MicrosoftAccount:ClientId"]; options.ClientSecret = Configuration["Authentication:MicrosoftAccount:ClientSecret"]; }); // Add MVC services to the services container. services.AddMvc(); //// Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. //// You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. //// services.AddWebApiConventions(); //// Register application services. //services.AddTransient<IEmailSender, AuthMessageSender>(); //services.AddTransient<ISmsSender, AuthMessageSender>(); var container = new Container(); container.Configure(x => { x.Scan(scanning => { scanning.Assembly(Assembly.GetExecutingAssembly()); scanning.TheCallingAssembly(); scanning.WithDefaultConventions(); }); //x.AddRegistry<WebsiteRegistry>(); }); // Our framework extension point container.Populate(services); }
Literally, the only things I have changed from the default template are the above code changes and installing
StructureMap
3.1.6.186.The using statements suppress all of the design time compilation errors, but when I build, I get several other errors.
Error CS0012 The type 'Action<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 32
Error CS0012 The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 32
Error CS0012 The type 'Func<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 59
Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 59
Error CS0012 The type 'Type' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 63
Error CS0012 The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 63
Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 63
Error CS0012 The type 'Type' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 67
Error CS0012 The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 67
Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 67
Error CS0012 The type 'Type' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 89
Error CS0012 The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 89
Error CS0411 The type arguments for method 'IContainer.GetInstance(string)' cannot be inferred from the usage. Try specifying the type arguments explicitly. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 89
Error CS0012 The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 107
Error CS0012 The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 107
Error CS0012 The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 120
Error CS1061 'IContainer' does not contain a definition for 'Dispose' and no extension method 'Dispose' accepting a first argument of type 'IContainer' could be found (are you missing a using directive or an assembly reference?) TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Services\StructureMapRegistration.cs 120
Error CS0012 The type 'Action<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Startup.cs 94
Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Startup.cs 94
Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Startup.cs 107
Error CS0012 The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Startup.cs 107
Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. TestDI3.DNX Core 5.0 f:\Users\Shad\documents\visual studio 2015\Projects\TestDI3\src\TestDI3\Startup.cs 107
The error indicates where the problem is - I need a reference to mscorlib 2.0.5.0. But I am already referencing mscorlib 4.0.0.0 in the project.
At this point in ASP.NET < 5, the next step would typically be to add some binding redirects to the
<bindingRedirect>
section of the web.config file. However, after searching for how to do this in ASP.NET 5, I came across this answer which indicates that binding redirection is supposed to be "totally automatic".So is this a bug, or is there some step in my configuration that I missed that is resulting in this error?
Configuration
DNX 1.0.0-beta5
.NET Framework
x86
IIS Express
project.json
{ "webroot": "wwwroot", "userSecretsId": "aspnet5-TestDI3-1665343b-5aa5-4d08-8596-a1a536223a19", "version": "1.0.0-*", "dependencies": { "EntityFramework.SqlServer": "7.0.0-beta5", "EntityFramework.Commands": "7.0.0-beta5", "Microsoft.AspNet.Mvc": "6.0.0-beta5", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5", "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta5", "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta5", "Microsoft.AspNet.Authentication.Google": "1.0.0-beta5", "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5", "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta5", "Microsoft.AspNet.Diagnostics": "1.0.0-beta5", "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5", "Microsoft.AspNet.Identity.EntityFramework": "3.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.Configuration.Abstractions": "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", "structuremap": "3.1.6.186" }, "commands": { "web": "Microsoft.AspNet.Hosting --config hosting.ini", "ef": "EntityFramework.Commands" }, "frameworks": { "dnx451": { }, "dnxcore50": { } }, "exclude": [ "wwwroot", "node_modules", "bower_components" ], "publishExclude": [ "node_modules", "bower_components", "**.xproj", "**.user", "**.vspscc" ], "scripts": { "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ] } }
解决方案Thanks to opiants, the problem appears to be related to the fact that the
dnxcore50
framework was included in the project."frameworks": { "dnx451": { }, "dnxcore50": { } }
Removing it solved the issue.
"frameworks": { "dnx451": { } }
这篇关于我该怎么办时,ASP.NET 5(vNext)不能重定向的绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!