[英]WebAPI OData could not load microsoft.data.odata version=5.6.0.0
When I construct Asp.Net WebAPI using VisualStudio 2013, adding 当我使用VisualStudio 2013构造Asp.Net WebAPI时,添加
Web API 2 OData Controller with actions using Entity FrameWork
Web API 2 OData控制器,具有使用实体框架的操作
after add successfully, I run the API, then the error occur: 添加成功后,我运行API,然后发生错误:
Could not load file or assembly 'Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
无法加载文件或程序集“ Microsoft.Data.OData,版本= 5.6.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference.
找到的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040)
(来自HRESULT的异常:0x80131040)
How to solve it? 怎么解决呢?
I spend long time to try and seems find the solution: 我花了很长时间尝试,似乎找到了解决方法:
1. Open Tools > Library Package Manager > Manage Nuget Packages For solution 1.打开工具>库包管理器>管理Nuget包以获取解决方案
and serach the word "data" shows: 并搜索“数据”一词将显示:
2. As the error says Microsoft.Data.OData, Version=5.6.0.0" Could not load
, you can find that there's Microsoft.Data.OData
installed here, name OdataLib for OData v1-3
, but its version is 5.6.3 not 5.6.0.0 2.如错误提示
Microsoft.Data.OData, Version=5.6.0.0" Could not load
,您可以发现这里安装了Microsoft.Data.OData
,名称OdataLib for OData v1-3
,但其版本为5.6.3。不是5.6.0.0
3. Hence now manage it and uncheck all project to uninstall it, but you'll meet the error Microsoft.AspNet.WebApi.OData 5.0.0 depends on it
, hence you should first uninstalled Microsoft.AspNet.WebApi.OData 5.0.0
3.因此,现在对其进行管理,并取消选中所有项目以将其卸载,但是您将遇到错误
Microsoft.AspNet.WebApi.OData 5.0.0 depends on it
,因此您应首先卸载Microsoft.AspNet.WebApi.OData 5.0.0
4. Then Uninstall other three packages, their id are : 4.然后卸载其他三个软件包,它们的ID为:
. 。
Microsoft.Data.OData
Microsoft.Data.Edm
System.Spatial
5. reinstall Microsoft.Data.OData -Version 5.6.0
5.重新安装
Microsoft.Data.OData -Version 5.6.0
https://www.nuget.org/packages/Microsoft.Data.OData/5.6.0 https://www.nuget.org/packages/Microsoft.Data.OData/5.6.0
using Package Manager Console 使用软件包管理器控制台
Install-Package Microsoft.Data.OData -Version 5.6.0
安装软件包Microsoft.Data.OData-版本5.6.0
then the three orange will be reinstall with ver 5.6.0.0 然后三个橙色将重新安装与版本5.6.0.0
6. reinstall Microsoft.AspNet.WebApi.OData 5.0.0
6.重新安装
Microsoft.AspNet.WebApi.OData 5.0.0
https://www.nuget.org/packages/Microsoft.AspNet.WebApi.OData/5.0.0 https://www.nuget.org/packages/Microsoft.AspNet.WebApi.OData/5.0.0
using Package Manager Console 使用软件包管理器控制台
Install-Package Microsoft.AspNet.WebApi.OData -Version 5.0.0
安装软件包Microsoft.AspNet.WebApi.OData-版本5.0.0
7. Then I can run the API without error 7.然后,我可以正确运行API
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.