2013-09-21 67 views
1

我一直在嘗試創建一個包含圖像文件的Windows Azure Blob。我遵循這些教程:http://www.nickharris.net/2012/11/how-to-upload-an-image-to-windows-azure-storage-using-mobile-services/http://www.windowsazure.com/en-us/develop/mobile/tutorials/upload-images-to-storage-dotnet/。最後,下面的代碼表示它們的合併。在最後一行,但是,將引發一個異常:Windows Azure Blob

類型「System.TypeLoadException」的異常出現在 mscorlib.ni.dll但在用戶代碼

其他信息沒有處理:一綁定指定的類型名稱不是 找到。 (來自HRESULT的例外:0x80132005)

即使容器被創建表,但它不能正常工作。

private async void SendPicture() 
{ 
    StorageFile media = await StorageFile.GetFileFromPathAsync("fanny.jpg"); 

    if (media != null) 
    { 
     //add todo item to trigger insert operation which returns item.SAS 
     var todoItem = new Imagem() 
     { 
      ContainerName = "mypics", 
      ResourceName = "Fanny", 
      ImageUri = "uri" 
     }; 
     await imagemTable.InsertAsync(todoItem); 

     //Upload image direct to blob storage using SAS and the Storage Client library for Windows CTP 
     //Get a stream of the image just taken 
     using (var fileStream = await media.OpenStreamForReadAsync()) 
     { 
      //Our credential for the upload is our SAS token 
      StorageCredentials cred = new StorageCredentials(todoItem.SasQueryString); 
      var imageUri = new Uri(todoItem.SasQueryString); 

      // Instantiate a Blob store container based on the info in the returned item. 
      CloudBlobContainer container = new CloudBlobContainer(
        new Uri(string.Format("https://{0}/{1}", 
         imageUri.Host, todoItem.ContainerName)), cred); 

      // Upload the new image as a BLOB from the stream. 
      CloudBlockBlob blobFromSASCredential = 
        container.GetBlockBlobReference(todoItem.ResourceName); 
      await blobFromSASCredential.UploadFromStreamAsync(fileStream.AsInputStream()); 
     } 
    } 
} 
+0

你能告訴你代碼中的哪一行出現異常嗎? –

+0

On: await blobFromSASCredential.UploadFromStreamAsync(fileStream.AsInputStream()); 謝謝Gaurav Mantri。 – igorvpcleao

回答

1

請使用Assembly Binding Log Viewer來查看哪個負載失敗。同樣在文章中提到,公共語言運行時未能定位程序集,通常在應用程序中顯示爲TypeLoadException。