Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure SDK Storage assembly not found exception when publishing

I try to publish a demo application to Windows Azure using Cloud Service and Azure SDK 2.9. In my service I have a Web Role and a Worker Role. Both use Azure Storage. Everything works fine on local hosting (Emulator) but when I try to publish the app I get the following error on Web Role:

Unhandled Exception: System.Runtime.Serialization.SerializationException,
Details: Exception: Unable to find assembly 'Microsoft.WindowsAzure.Storage, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf385)

In the Worker Role project everything is OK, it's using Storage too.

I tried to convert the Web Role to a standard Web Application and everything works fine but I want to resolve this problem on Cloud Application.

What I've tried:

  • set local copy in references to true
  • changed .Net Framework to 4.5.1 and 4.6 (default 4.5)
  • removed and added reference to Storage again
  • reinstalled all libraries by nuget
  • published with Storage 7.0 and 6.2
  • published by VS and by portal (package)
  • added dependentAssembly to web.config

On my VM I checked the bin folder, Microsoft.WindowsAzure.Storage exists.

Any ideas what is wrong?

like image 685
Kisiel665 Avatar asked Dec 05 '25 07:12

Kisiel665


1 Answers

After two days I found a solution for that problem. In my WebRole.cs I had this:

public override bool OnStart()
{
    var csa = CloudStorageAccount.Parse(RoleEnvironment
        .GetConfigurationSettingValue("Credentials"));
    var cqc = csa.CreateCloudQueueClient();
    var inputQueue = cqc.GetQueueReference("inputqueue");
    inputQueue.CreateIfNotExists();
    var outputQueue = cqc.GetQueueReference("outputqueue");
    outputQueue.CreateIfNotExists();
    var ctc = csa.CreateCloudTableClient();
    var ct = ctc.GetTableReference("last");
    ct.CreateIfNotExists();
    return base.OnStart();
}

When I moved this initialization to other place e.g. to RouteConfig.cs everything works perfect. I don't know why but every references to Storage from WebRole throws errors after publishing to Azure. I hope this solution helps.

like image 91
Kisiel665 Avatar answered Dec 07 '25 21:12

Kisiel665



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!