Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in loading Azure Storage 2.0 -- could not load Microsoft.Data.OData 5.0.2

My hosted service uses Azure Storage 2.0 (exactly 2.0.5.1 from Nuget). Under Visual Studio 2010 I had no problem. I switched to Visual Studio 2012 and now in some web site of my main web role I get the following exception of type 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)

while Azure Storage 2.0.5.1 requires Microsoft.Data.OData 5.2.0.0 . The other worker roles work just fine and they seem to find the correct assembly. In every project Azure Storage 2.0 is installed from Nuget and all the references point to the packages folder.

I use Azure SDK 1.8 under .NET 4.0 -- this means that I also employ Azure Storage Client 1.7.

like image 457
edymtt Avatar asked Oct 05 '22 05:10

edymtt


1 Answers

After a little investigation, I discovered that this web site loaded Microsoft.WindowsAzure.Storage from the SDK path, the same path from which I loaded Microsoft.WindowsAzure.StorageClient in other assemblies -- in the Modules windows in Visual Studio I can see that iisexpress loads the assembly with file version 2.0.0.0 . To my understanding the reference to Microsoft.WindowsAzure.StorageClient can force Visual Studio to load Microsoft.WindowsAzure.Storage from the wrong path.

After a bit of fiddling, I've moved the Microsoft.WindowsAzure.Storage assembly out of SDK folder, forcing Visual Studio to reference the assembly downloaded by Nuget -- this way I had no problem.

An an alternative, I could also move Microsoft.WindowsAzure.StorageClient to another location and change the references in my project -- but this will be quite useless since I plan to move to Azure Storage 2.0 entirely (for example, I hope that in Azure SDK 2.0 Diagnostics uses Storage 2.0).

like image 88
edymtt Avatar answered Oct 13 '22 12:10

edymtt