3

I'm working on my Mobile Backend/Web API for my Azure Mobile Service and I got this message when I tried to debug the code. The Azure Configuration code exists in a different C# Class Library and I believe there's a version mismatch between them.

Additional information: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=3.0.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)

The error comes form this line:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("photos");

The above lines are used to upload an image blob to my Blob Storage. I believe it's a version mismatch between the backend and the Azure Cloud APIs. What do you think this error means?

Dinuka Jay
  • 4,233
  • 6
  • 53
  • 121
  • 1
    Have you upgraded the the package so it is on the same version across all projects? – Devon Burriss Sep 06 '15 at 14:39
  • 1
    That's what I can't do. When it tries to update, it says that another package is not compatible with the newer version! What is the correct method of upgrading all the packages? @deebo – Dinuka Jay Sep 06 '15 at 14:55
  • What package does NuGet say is not compatible? You might not have to upgrade all packages. You can however use `Update-Package -Project ProjectName` from the package manager console to upgrade all packages in a project. Of course, upgrading all package might lead to other problems. – Shaun Luttin Sep 06 '15 at 15:18
  • as in "Update-Package -Project mywebProject" ? @ShaunLuttin – Dinuka Jay Sep 06 '15 at 15:29
  • Yes. `Update-Package -Project myWebProject` or `Update-Package -Project myClassLibrary`. – Shaun Luttin Sep 06 '15 at 15:30
  • 1
    @ShaunLuttin I realized the problem. The Package "Microsoft.WindowsAzure.Configuration" has a version of 2.0.0.0 in my Web API Project while the Class Library has a version of "3.0.0.0". This might be the problem. Is there a way to downgrade my class library to 2.0.0.0? I dont want to upgrade since many other packages depends on the Web Project's Package. How can I downgrade? – Dinuka Jay Sep 06 '15 at 15:46
  • @ShaunLuttin Figured it out mate. Thank you for taking the time :) – Dinuka Jay Sep 06 '15 at 15:54
  • What was the answer? – Shaun Luttin Sep 06 '15 at 15:55
  • 1
    It was a version mismatch and I figured it out via reading through the list of answers you gave me. Basically the DLL version of the web project was different from the version of the Class Library it referenced and thus the clash. I had to downgrade the class library to the web project's dll version and it works – Dinuka Jay Sep 06 '15 at 15:59

1 Answers1

1

Half-Baked Ideas :)

Idea 1 Within both projects, open the packages.config file. See whether both files reference the same version of Microsoft.WindowsAzure.Configuration. If they differ, you can use the Package Manager Console to upgrade or downgrade one of the projects.

// update to a specific version of a package
Update-Package MyPackage -Version [an earlier or later version]

// update all packages within a project
Update-Package -Project ProjectName

Idea 2 Within both projects, also check the web.config > runtime > assemblyBinding section to see whether one has a problematic bindingRedirect for Microsoft.WindowsAzure.Configuration.

Idea 3 For a more comprehensive approach, use the Assembly Binding Log Viewer. To get started, from a Developer Command Prompt for Visual Studio, run Fuslogvw.exe.

Helpful Links

Troubleshooting NuGet references

The located assembly's manifest definition does not match the assembly reference

Updating All Packages

Could not load file or assembly… NuGet Assembly Redirects

Assembly Binding Log Viewer (Fuslogvw.exe)

Community
  • 1
  • 1
Shaun Luttin
  • 107,550
  • 65
  • 332
  • 414