Asp.net mvc 2 CreateIfNotExists的名称空间是什么?

Asp.net mvc 2 CreateIfNotExists的名称空间是什么?,asp.net-mvc-2,azure,Asp.net Mvc 2,Azure,在我的应用程序中,我试图将文档上载到Azure blob存储中。代码是: // Namespaces for Azure using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.StorageClient; public ActionResult GetPdf(HttpPostedFileBase document) { int pdfocument = Request.ContentLength; var doc

在我的应用程序中,我试图将文档上载到Azure blob存储中。代码是:

// Namespaces for Azure
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

public ActionResult GetPdf(HttpPostedFileBase document)
{
    int pdfocument = Request.ContentLength;

    var doctype=Request.ContentType;

    byte[] pdf = new byte[pdfocument];               
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("Setting1"));
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();           
    CloudBlobContainer container = blobClient.GetContainerReference("containername");
    container.CreateIfNotExists();
    var permissions = container.GetPermissions();
    permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
    container.SetPermissions(permissions);
    string uniqueBlobName = "blobname";
    CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName);
    blob.Properties.ContentType = doctype;
    blob.UploadByteArray(pdf);
}
当我构建我的应用程序时,我在
container.CreateIfNotExists()
处收到一个错误。错误是:

“Microsoft.WindowsAzure.StorageClient.CloudBlobContainer”不包含“CreateIfNotExists”的定义,并且找不到接受“Microsoft.WindowsAzure.StorageClient.CloudBlobContainer”类型的第一个参数的扩展方法“CreateIfNotExists”(是否缺少using指令或程序集引用?)


我可以为该错误添加哪个命名空间?

CreateIfNotExists是Azure库2.0版的一部分


如果您使用的是1.7版StorageClient名称空间,则需要调用CreateIfNotExist(无复数)

您好,Rob,您的信息是正确的。这对我非常有用。为此,我浪费了几个小时。非常感谢。@PCSSCP,如果它解决了您的问题,请将其标记为答案。