Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (45.3k points)

I have a very peculiar issue using Azure Table Storage. I have a .NET 4.5 project in Visual Studio 2012 where I deal with all my Azure Table Storage functions. This project/dll is referenced by two other projects, my MVC website, and my Azure Worker Role. (I am running under the Azure Emulators on my machine, but it also happens when I deploy it to the cloud)

I have the following function that is called when I save or retrieve a record:

internal static CloudTable GetTable(CloudStorageAccount storageAccount, string tableReference)

{

    CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

    CloudTable table = tableClient.GetTableReference(tableReference);

    table.CreateIfNotExists();

    return tableClient.GetTableReference(table.Name);

}

In my MVC website, I have a function that will save a record to an Azure Storage table, and then in my Azure Worker Role, there is a service that will read the record.

So both use the same dll for storage and retrieval. However, my MVC project has no issues saving the record, but in my Azure Worker role service when it tries to retrieve the record throws the exception when it attempts to execute "table.CreateIfNotExists();".

Could not load file or assembly 'Microsoft.Data.OData, Version=5.2.0.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)

I have done the following already:

  1. Updated all the NuGet packages from the solution level to the latest versions
  2. I went through every project reference to make sure that there are no old dll's or previous versions hanging around, in particular, the System.Spatial, Microsoft.WindowsAzure.Configuration, Microsoft.WindowsAzure.ServiceRuntime and Microsoft.ServiceBus, Microsoft.WindowsAzure.Storage, Microsoft.Data.Edm & Microsoft.Data.OData
  3. I have even created a new Cloud Service and WorkerRole project from scratch to make sure it is not something in the current WorkerRole project that is broken.

I have not rolled the dll's back to 5.2 as I had too many issues in other projects where I use features that are specific from 5.3 onwards.

I am currently running all the dll's on 5.5.

When I run the AsmSpy.exe utility found here, I get the following output that I am not 100% sure how to interpret.

> Reference: Microsoft.Data.Edm

>         5.5.0.0 by Microsoft.Data.OData

>         5.5.0.0 by Microsoft.Data.Services.Client

>         5.5.0.0 by Microsoft.WindowsAzure.ActiveDirectory.GraphHelper.2013_04_05

> Reference: System.Spatial

>         5.5.0.0 by Microsoft.Data.OData

>         5.5.0.0 by Microsoft.Data.Services.Client Reference: Microsoft.Data.OData

>         5.5.0.0 by Microsoft.Data.Services.Client

>         5.2.0.0 by Microsoft.WindowsAzure.Storage   <-- THIS SEEMS TO BE THE ONE THAT IS CAUSING ISSUES

How I interpret it, is that the Microsoft.WindowsAzure.Storage dll is referencing V 5.2.0.0 of the Microsoft.Data.OData dll, but how do I fix this, if this is the issue? According to the documentation I have seen on the Storage dll is that it is supposed to reference 5.4 and up, not 5.2...?

1 Answer

0 votes
by (16.8k points)

Try to upload the additional configuration in your config files  (web.config for the MVC and app.config for the worker role):

<runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>

        <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />

      </dependentAssembly>

      <dependentAssembly>

        <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />

      </dependentAssembly>

    </assemblyBinding>

  </runtime>

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...