我一直在嘗試創建一個包含圖像文件的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());
}
}
}
你能告訴你代碼中的哪一行出現異常嗎? –
On: await blobFromSASCredential.UploadFromStreamAsync(fileStream.AsInputStream()); 謝謝Gaurav Mantri。 – igorvpcleao