Sabine
Sabine

Reputation: 41

Com interop DLL to access Azure Storage

My customer needs a com interop dll to save and delete Windows Azure Blobs in the Storage (he uses VB6 and cannot call the Storage directly). I wrote a ComInterop DLL like this several times before, but now, when calling the DLL from a VB6 application, he gets a runtime file-not-found exception 80070002:

'Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

Any ideas?

Here a little code snippet:

[Serializable]
[Guid("...")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComSourceInterfaces(typeof(IBlobOperations))]
[ComVisible(true)]
[ProgId("...")]
public class BlobOperations
{


    #region (Aufrufbare Funktionen) ---------------------------------------
    private const string BlobConnection =
        "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...";

    private const string Container = "...";

    public void BlobChange(string fileLocation, string blobName)
    {
        try
        {
            var storageAccount = CloudStorageAccount.Parse(BlobConnection);

            // Create the blob client.
            var blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve reference to a previously created container.
            var container = blobClient.GetContainerReference(Container);

            // Retrieve reference to a blob named "myblob".
            var blockBlob = container.GetBlockBlobReference(blobName);

            // Create or overwrite the "myblob" blob with contents from a local file.
            using (var fileStream = System.IO.File.OpenRead(fileLocation))
            {
                blockBlob.UploadFromStream(fileStream);
            }
        }
        catch (Exception e)
        {
            ...
        }
    }

Upvotes: 2

Views: 357

Answers (1)

Brett Rigby
Brett Rigby

Reputation: 6216

You need to add a reference to the Microsoft.WindowsAzure.Storage.dll - this is installed locally on your dev machine when you install the Azure tools.

Simply find the file, reference it from your project and you should be ok.

Hope this helps.

Upvotes: 1

Related Questions