2

我的客户需要一个 com interop dll 来保存和删除存储中的 Windows Azure Blob(他使用 VB6 并且不能直接调用存储)。我以前多次写过这样的 ComInterop DLL,但是现在,当从 VB6 应用程序调用 DLL 时,他得到了一个运行时文件未找到异常 80070002:

'无法加载文件或程序集'Microsoft.WindowsAzure.Storage,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35'或其依赖项之一。

有任何想法吗?

这里有一个小代码片段:

[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)
        {
            ...
        }
    }
4

1 回答 1

1

您需要添加对 Microsoft.WindowsAzure.Storage.dll 的引用 - 当您安装 Azure 工具时,它会在您的开发机器上本地安装。

只需找到该文件,从您的项目中引用它,就可以了。

希望这可以帮助。

于 2012-12-28T08:01:58.707 回答