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/。最后,以下代码表示它们的合并。然而,在最后一行引发了一个异常:

mscorlib.ni.dll 中出现“System.TypeLoadException”类型的异常,但未在用户代码中处理

附加信息:未找到指定类型名称的绑定。(来自 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());
        }
    }
}
4

1 回答 1

1

请使用程序集绑定日志查看器查看哪个加载失败。正如文章中提到的,公共语言运行时无法定位程序集通常会在您的应用程序中显示为 TypeLoadException。

于 2013-09-30T18:24:31.930 回答