我的客户需要一个 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/