azure - 用于访问 Azure 存储的 Com 互操作 DLL

标签 azure com-interop azure-storage

我的客户需要一个 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)
        {
            ...
        }
    }

最佳答案

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

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

希望这有帮助。

关于azure - 用于访问 Azure 存储的 Com 互操作 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14066330/

相关文章:

Azure SQL 数据库连接有时很慢

azure - 无法识别“New-AzSqlServerFirewallRule” - Azure Dev Ops Pipeline 的 Azure PowerShell 问题

.net - 需要使用 .NET 支持复制 IDispatch*;不知道类(class)名称

c# - C#中_bstr_t的等价物是什么

c# - 正确关闭 C# excel COM 对象

c# - 将图像从 Windows Phone 上传到 Azure Blob 存储。不创建

c# - AzureStorage 库 v2 中的 "tableClient.CreateTableIfNotExist"在哪里?

azure - Azure Cloud Shell 中 mkdir 所需的 Sudo 权限

performance - 负载测试自动化作为 VSTS 发布管道的一部分

azure-storage - 将文件从 Azure BLOB 存储复制到 SharePoint 文档库