2012-12-28 58 views
2

我的客戶需要一個COM互操作DLL來保存和刪除存儲中的Windows Azure Blob(他使用VB6,不能直接調用存儲)。我以前多次寫過這樣的ComInterop DLL,但現在,當從VB6應用程序調用DLL時,他得到運行時文件 - 未找到異常80070002:Com interop DLL訪問Azure存儲

'無法加載文件或程序集'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) 
     { 
      ... 
     } 
    } 

回答

1

您需要添加到Microsoft.WindowsAzure.Storage.dll參考 - 這是本地安裝您的開發機器上,當您安裝Azure工具。

只需找到該文件,從您的項目中引用它,你應該沒問題。

希望這會有所幫助。

+0

我確實有這個DLL的參考。從測試項目中,一切都很完美。我可以像charme一樣添加和刪除斑點。只有從vb6(com互操作),這個運行時異常發生。對不準確的錯誤。 – Sabine

+0

當您的應用程序構建時是否將此參考集複製到您的Bin文件夾?如果您使用的是測試機器,則可能會在GAC或某處註冊此文件,但在他的PC上則可能不會。 –

+0

我想,你是對的。 「本地副本」設置爲true。我會檢查出來併發布答案。謝謝!!! – Sabine