"Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7
1、错误背景
系统安装了.net framework4.0、4.5,项目先使用VS2013(4.5)开发,后来又重新用VS2010开发(4.0),运行时出现这个错误
2、错误原因
In .Net 4.5 the ExtensionAttribute
class was moved from System.Core to mscorlib.
ExtensionAttribute
类在4.5中从System.Core迁移到mscorlib中,项目运行时会按4.5的方法寻找导致异常。
有人会说,项目都是按4.0编译的,4.5也卸载了,为什么还会出现此问题?原因在于引用的第三方类库可能还是关联的4.5版本,比如我遇到这个问题是由于Entityframework引用了4.5版本导致的,而4.0和4.5从dll属性中看不出来
3、解决方法
拿entityframework举例,用nuget下载entityframework,生成的packages\EntityFramework.6.0.2\lib文件夹中会有net40和net45两个文件夹,引用.net4.0文件夹中的dll即可
"Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7的更多相关文章
- Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib 的一种情形
没有引用任何.net 4.5的东西,也没有引用 Newtonsoft.dll,原因是引用了微软的tlb类型库,引用方法如 https://www.cnblogs.com/nanfei/p/108798 ...
- Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute'
[TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from as ...
- 解决方法:Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
最近使用VS2015调试ASP.NET 程序遇到了该问题: 在网上找了很多方法都不能解决,最后自己解决了,方法如下: 在project -> NuGet管理中找到已安装的所有程序:将Web Op ...
- 缺少编译器要求的成员“System.Runtime.CompilerServices.ExtensionAttribute..ctor” 解决方案
我自己使用的解决方法 错误产生环境及非完美解决办法 错误提示:缺少编译器要求的成员"System.Runtime.CompilerServices.ExtensionAttribute..c ...
- 缺少编译器要求的成员“System.Runtime.CompilerServices.ExtensionAttribute..ctor” 解决方案
静态类中添加如下.此方法本人测试有效. //缺少编译器要求的成员“ystem.Runtime.CompilerServices.ExtensionAttribute..ctor” namespace ...
- 解决System.Runtime.CompilerServices.ExtensionAttribute..ctor 与 ‘ExtensionAttribute’ is ambiguous in the namespace ‘System.Runtime.CompilerServices’ 问题
从VSS上获取以前的老项目,编译时报System.Runtime.CompilerServices.ExtensionAttribute..ctor 网上写的“删除 Newtonsoft.Json.N ...
- Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, ...
- System.TypeLoadException: Could not load type 'System.IO.Compression.CompressionLevel' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1.提示错误信息: zipSystem.TypeLoadException: Could not load type 'System.IO.Compression.CompressionLevel' ...
- Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0,"解决办法
这是因为先安装了 .NET Framework 4,随后启用了 .NET Framework 3.5 WCF HTTP 激活,则会发生此错误. 只需要已管理员用户在cmd中运行aspnet_regii ...
随机推荐
- 后台获取ajax发送过来的值
user.CityId = int.Parse(HttpContext.Request[ "bindArea"]); 以上为获取方法:
- 移动Web轮播图IOS卡顿的问题
晚饭前,被测试吐槽说,banner轮播手动左右滑的时候会卡顿.我一看不科学啊,大水果手机怎么会卡顿.我一看测试手中拿的是iPod,我觉得大概是这小玩意性能不强悍,后来又拿来5S,依然会卡顿,有趣的是, ...
- 8款效果惊艳的HTML5 3D动画
1.HTML5 WebGL水面水波荡漾特效 之前已经向各位分享过一款很逼真的HTML5水波荡漾特效,效果还算不错.今天再向大家分享一款更加给力的HTML5水波动画,画面上是一个大水池,水池底部是一颗大 ...
- BMP文件格式分析
前两天要做一个读取bmp文件的小程序,顺便查找了一些关于BMP格式的文章,现在post上来. 简介 BMP(Bitmap-File)图形文件是Windows采用的图形文件格式,在Windows环境下运 ...
- Linux驱动编程--基于I2C子系统的I2C驱动
代码中,我添加了很多注释,应该不难理解,有错误大家可以指出来,我再改正 #include <linux/kernel.h> #include <linux/module.h> ...
- IOS引导页拨动4张图片最后一张停三秒进入主页,页面推送
// // ViewController.m // // // Created by 张艳锋 on 15/8/26. // Copyright (c) 2015年 张艳锋. All rights ...
- activiti系列导读
此用于管理activiti系列标签文章,activiti的分析是建立在目前最新的版本5.21之上. 官方指导手册链接:http://www.activiti.org/userguide/index.h ...
- 转载:Linux内核探索之路——关于书
转自http://blog.chinaunix.net/uid-20608849-id-3029223.html 在学习Linux内核代码的过程中,定会参考很多书籍以及网路资源,但是并不是所有的书籍和 ...
- CentOS 5.8 升级php版本
一:我们都知道系统的yum源安装出来的php版本不是5.1的就是5.3 那就是说 有些程序不支持那么低的版本的呢 那我们该怎么办呢 接下来 简单的说下php的版本升级 编译升级太慢了 这里我们选择 ...
- Lucene 4.0
关于4.0的Update Index ,Create Index /* * Create Index */ public static void createIndex() throws IOExc ...