加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

.net – 加载Azure Storage 2.0时出错 – 无法加载Microsoft.Dat

发布时间:2020-12-13 21:32:06 所属栏目:Windows 来源:网络整理
导读:我的托管服务使用Azure Storage 2.0(来自Nuget的2.0.5.1).在Visual Studio 2010下我没有问题.我切换到Visual Studio 2012,现在在我的主要Web角色的某个网站上,我得到以下类型的Microsoft. WindowsAzure.Storage.StorageException异常: Could not load file
我的托管服务使用Azure Storage 2.0(来自Nuget的2.0.5.1).在Visual Studio 2010下我没有问题.我切换到Visual Studio 2012,现在在我的主要Web角色的某个网站上,我得到以下类型的Microsoft. WindowsAzure.Storage.StorageException异常:
Could not load file or assembly 'Microsoft.Data.OData,Version=5.0.2.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
The located assembly's manifest definition does not match
the assembly reference. (Exception from HRESULT: 0x80131040)

而Azure Storage 2.0.5.1需要Microsoft.Data.OData 5.2.0.0.其他工作者角色工作正常,他们似乎找到了正确的程序集.在每个项目中,Azure Storage 2.0都是从Nuget安装的,所有引用都指向packages文件夹.

我在.NET 4.0下使用Azure SDK 1.8 – 这意味着我还使用Azure Storage Client 1.7.

经过一番调查,我发现这个网站从SDK路径加载了Microsoft.WindowsAzure.Storage,我在其他程序集中加载了Microsoft.WindowsAzure.StorageClient的相同路径 – 在Visual Studio的Modules窗口中我可以看到iisexpress使用文件版本2.0.0.0加载程序集.据我所知,对Microsoft.WindowsAzure.StorageClient的引用可以强制Visual Studio从错误的路径加载Microsoft.WindowsAzure.Storage.

经过一番摆弄后,我将Microsoft.WindowsAzure.Storage程序集移出SDK文件夹,强制Visual Studio引用Nuget下载的程序集 – 这样我没有问题.

另外一种选择,我也可以将Microsoft.WindowsAzure.StorageClient移动到另一个位置并更改我项目中的引用 – 但由于我打算完全迁移到Azure Storage 2.0,因此这将毫无用处(例如,我希望在Azure中SDK 2.0 Diagnostics使用Storage 2.0).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读