Share via


Workaround für FileLoadException mit Microsoft.WindowsAzure.Storage Version 3.1.0.1

Wer aktuell Probleme bei der Ausführung der Windows Azure Storage Bibliothek Version 3.1.0.1 hat und die Fehlermeldung bekommt, dass die Assembly Microsoft.Data.Services.Client, Version 5.6.0.0 nicht gefunden werden kann, wird der folgende Workaround interessieren.

Problem

Wenn ich stand heute (24.04.2014) das NuGet-Paket für die Windows Azure Storage Bibliothek installieren möchte, erhalte ich die folgende Fehlermeldung, sobald ich Blobs, Tables oder Queues erstellen möchte.

image

image

An unhandled exception of type 'System.IO.FileLoadException' occurred in Microsoft.WindowsAzure.Storage.dll

Additional information: Die Datei oder Assembly "Microsoft.Data.Services.Client, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)

Lösung

Das Problem liegt anscheinend darin begründet, dass bei der Installation des NuGet-Pakets WindowsAzure.Storage die Assembly Microsoft.Data.Services.Client in der Version 5.6.1 installiert wird, womit die Azure Storage Bibliothek Version 3.1.0.1 nicht kompatibel ist.

Also deinstalliere ich alle relevanten Assemblies und installiere sie mit der korrekten Version erneut.

Für die folgenden Schritte kann es hilfreich sein, die Datei packages.config zu öffnen, damit man weiß, wie die NuGet-Pakete heißen.

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Data.Edm" version="5.6.1" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.1" targetFramework="net45" />
<package id="Microsoft.Data.Services.Client" version="5.6.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="1.8.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.1" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="3.1.0.1" targetFramework="net45" />
</packages>

Über das Menü Tools, Library Package Manager die Package Manager Console aufrufen.

image

Über die Package Manager Console deinstallieren wir der Reihe nach folgende Pakete:

  1. WindowsAzure.Storage
  2. Microsoft.Data.Services.Client
  3. Microsoft.Data.OData
  4. Microsoft.Data.Edm
  5. System.Spatial

Die jeweils erste und fettgedruckte Zeile enthält den einzugebenden Befehl.

PM> UnInstall-Package WindowsAzure.Storage
Removing 'WindowsAzure.Storage 3.1.0.1' from ConsoleQueues.
Successfully removed 'WindowsAzure.Storage 3.1.0.1' from ConsoleQueues.
Uninstalling 'WindowsAzure.Storage 3.1.0.1'.
Successfully uninstalled 'WindowsAzure.Storage 3.1.0.1'.

PM> UnInstall-Package Microsoft.Data.Services.Client
Removing 'Microsoft.Data.Services.Client 5.6.1' from ConsoleQueues.
Successfully removed 'Microsoft.Data.Services.Client 5.6.1' from ConsoleQueues.
Uninstalling 'Microsoft.Data.Services.Client 5.6.1'.
Successfully uninstalled 'Microsoft.Data.Services.Client 5.6.1'.

PM> Uninstall-Package Microsoft.Data.OData
Removing 'Microsoft.Data.OData 5.6.1' from ConsoleQueues.
Successfully removed 'Microsoft.Data.OData 5.6.1' from ConsoleQueues.
Uninstalling 'Microsoft.Data.OData 5.6.1'.
Successfully uninstalled 'Microsoft.Data.OData 5.6.1'.

PM> UnInstall-Package Microsoft.Data.Edm
Removing 'Microsoft.Data.Edm 5.6.1' from ConsoleQueues.
Successfully removed 'Microsoft.Data.Edm 5.6.1' from ConsoleQueues.
Uninstalling 'Microsoft.Data.Edm 5.6.1'.
Successfully uninstalled 'Microsoft.Data.Edm 5.6.1'.

PM> UnInstall-Package System.Spatial
Removing 'System.Spatial 5.6.1' from ConsoleQueues.
Successfully removed 'System.Spatial 5.6.1' from ConsoleQueues.
Uninstalling 'System.Spatial 5.6.1'.
Successfully uninstalled 'System.Spatial 5.6.1'.

Jetzt die Version 5.6.0 von Microsoft.Data.Services.Client installieren und danach wieder WindowsAzure.Storage.

PM> Install-Package Microsoft.Data.Services.Client -Version 5.6.0
Attempting to resolve dependency 'Microsoft.Data.OData (= 5.6.0)'.
Attempting to resolve dependency 'System.Spatial (= 5.6.0)'.
Attempting to resolve dependency 'Microsoft.Data.Edm (= 5.6.0)'.
Installing 'System.Spatial 5.6.0'.
You are downloading System.Spatial from Microsoft Corporation, the license agreement to which is available at https://go.microsoft.com/?linkid=9809688. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'System.Spatial 5.6.0'.
Installing 'Microsoft.Data.Edm 5.6.0'.
You are downloading Microsoft.Data.Edm from Microsoft Corporation, the license agreement to which is available at https://go.microsoft.com/?linkid=9809688. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Data.Edm 5.6.0'.
Installing 'Microsoft.Data.OData 5.6.0'.
You are downloading Microsoft.Data.OData from Microsoft Corporation, the license agreement to which is available at https://go.microsoft.com/?linkid=9809688. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Data.OData 5.6.0'.
Installing 'Microsoft.Data.Services.Client 5.6.0'.
You are downloading Microsoft.Data.Services.Client from Microsoft Corporation, the license agreement to which is available at https://go.microsoft.com/?linkid=9809688. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Data.Services.Client 5.6.0'.
Adding 'System.Spatial 5.6.0' to ConsoleQueues.
Successfully added 'System.Spatial 5.6.0' to ConsoleQueues.
Adding 'Microsoft.Data.Edm 5.6.0' to ConsoleQueues.
Successfully added 'Microsoft.Data.Edm 5.6.0' to ConsoleQueues.
Adding 'Microsoft.Data.OData 5.6.0' to ConsoleQueues.
Successfully added 'Microsoft.Data.OData 5.6.0' to ConsoleQueues.
Adding 'Microsoft.Data.Services.Client 5.6.0' to ConsoleQueues.
Successfully added 'Microsoft.Data.Services.Client 5.6.0' to ConsoleQueues.

PM> Install-Package WindowsAzure.Storage
Attempting to resolve dependency 'Microsoft.Data.OData (≥ 5.6.0)'.
Attempting to resolve dependency 'System.Spatial (= 5.6.0)'.
Attempting to resolve dependency 'Microsoft.Data.Edm (= 5.6.0)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 5.0.6)'.
Attempting to resolve dependency 'Microsoft.Data.Services.Client (≥ 5.6.0)'.
Attempting to resolve dependency 'Microsoft.WindowsAzure.ConfigurationManager (≥ 1.8.0.0)'.
Installing 'WindowsAzure.Storage 3.1.0.1'.
You are downloading WindowsAzure.Storage from Microsoft, the license agreement to which is available at https://go.microsoft.com/fwlink/?LinkId=331471. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'WindowsAzure.Storage 3.1.0.1'.
Adding 'WindowsAzure.Storage 3.1.0.1' to ConsoleQueues.
Successfully added 'WindowsAzure.Storage 3.1.0.1' to ConsoleQueues.

Dies hat das oben beschriebene Problem bei mir gelöst. Auf die Lösung bin ich Dank des Beitrags “Missing Microsoft.Data.Services.Client version 5.6 on Azure Websites” auf Stack Overflow gekommen. Vielen Dank an dieser Stelle!

Wem das jetzt zu viel Text war, hier noch einmal alle einzugebenden Befehle zusammengefasst:

  1. UnInstall-Package WindowsAzure.Storage
  2. UnInstall-Package Microsoft.Data.Services.Client
  3. Uninstall-Package Microsoft.Data.OData
  4. UnInstall-Package Microsoft.Data.Edm
  5. UnInstall-Package System.Spatial
  6. Install-Package Microsoft.Data.Services.Client -Version 5.6.0
  7. Install-Package WindowsAzure.Storage

Zum Vergleich, danach sieht die packages.config folgendermaßen aus. Man sieht, dass nun die Version 5.6.0 installiert wurde.

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="1.8.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="3.1.0.1" targetFramework="net45" />
</packages>