"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 ...
随机推荐
- Linux 基本命令学习笔记
1. 文件管理 Ø touch 新建文件.例: touch test.txt 新建一个test.txt 文件. Ø cp 复制文件.例:cp ./user_one/test_one ./user ...
- 百度编辑器ueditor前台代码高亮无法自动换行解决方法
这两天本站成功安装整合了百度编辑器ueditor,用着还挺不错,但是遇到了点小问题 问题描述: 在内容里面插入代码高亮显示,后台编辑器中是可以自动换行的,但是发表后,在前台查看,发现代码不能自动换 ...
- TreeView控件的CheckBox级联选中或取消
背景: 在一个项目开发中遇到这样的要求:当选中树中一个节点时,需要同时选中其父节点,直至根节点.在取消一个节点的选中时,需要将其所有子节点取消选中,直至叶子节点.由于项目用户体验暂时可以不用考虑,直接 ...
- 多文件上传artDialog+plupload
一.效果展示 包括文件上传面板以及文件上传列表 二.介绍 长话短说,采用spring springMVC mybatis maven mysql,实现多文件上传功能,下载使用的是流的形式. 其中涉及的 ...
- SPL标准库常用的数据结构
栈数据结构 $stack = new SplStack(); //栈数据结构->先进后出 2 $stack->push('data1'); //入栈 $stack->push('da ...
- linux 安装sysstat使用iostat、mpstat、sar、sa(转载)
使用yum安装 #yum install sysstat sysstat的安装包是:sysstat-5.0.5-1.i386.rpm,装完了sysstat-5.0.5-1.i386.rpm后 就会有i ...
- Centos6.4版本下搭建LAMP环境
Centos6.4版本下搭建LAMP环境 配置yum mkdir/mnt/cdrom mount/dev/cdrom /mnt/cdrom 装载光盘 vi /etc/yum.repos.d/Cent ...
- 更改windows服务的配置文件app.config
/// <summary> /// 获取每次处理记录数 /// </summary> /// <returns></returns> private s ...
- Mod 与 RequireJS/SeaJS 的那些事
本文的目的是为了能大让家更好的认识 Mod,之所以引入 RequireJS/SeaJS 的对比主要是应大家要求更清晰的对比应用场景,并不是为了比较出孰胜孰劣,RequireJS 和 SeaJS 都是模 ...
- WPF的UI布局(Layout)WPF读书笔记(第三天)
WPF的布局元素有一下几个 Grid:网格.可以自定义行和列并且通过行列的数目.行高和列宽来调整控件的布局. StackPanel:格式面板.可将包含的元素在水平方向或者竖直方向排成一条线. ...