Avkash Chauhan's Blog

Windows Azure, Windows 8, Cloud Computing, Big Data and Hadoop: All together at one place.. One problem, One solution at One time...

Console application using Windows Azure Storage Client Library with Windows Azure SDK

Console application using Windows Azure Storage Client Library with Windows Azure SDK

Rate This
  • Comments 7

If you create a Console Application in VS 2010:

1.      Add reference DLL:

Microsoft.WindowsAzure.StorageClient

1.      Add code:

using Microsoft.WindowsAzure;

using Microsoft.WindowsAzure.StorageClient;


When you compile this application you will get the following error:

Error Details:

  • The referenced assembly "Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
  • The type or namespace name 'WindowsAzure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

If you check application settings for .NET platform version, you will see  .NET platform version is set to 4.0 Client Profile by default thats why you received this error. Now if you can change the .NET platform version to 3.5 or 4.0 and recompile the application and error will be resolved.  

Here is the sample code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.WindowsAzure.StorageClient;

using Microsoft.WindowsAzure;

 

namespace AzureStroageTest

{

    class Program

    {

        private static CloudStorageAccount account;

        private static CloudBlobClient blobClient;

        private static CloudBlobContainer container;

 

        public static void ConnectStorage(string containerName)

        {

                account = new CloudStorageAccount(new StorageCredentialsAccountAndKey("<Enter_storage_account_name>", "<Enter_storage_account_key>"), true);

                blobClient = new CloudBlobClient(account.BlobEndpoint.AbsoluteUri, account.Credentials);

                container = blobClient.GetContainerReference(containerName);

                container.CreateIfNotExist();

                Console.WriteLine("Success");

        }

 

        static void Main(string[] args)

        {

            ConnectStorage("<Enter_container_name>");

        }

    }

}

 

 

Leave a Comment
  • Please add 7 and 1 and type the answer here:
  • Post
  • In VS 2010 console Application, default is 4.0 client profile.  The time you can not use Azure library.

    If you use 4.0 full profile. It works fine. Just try it.

  • Hi,

    Thanks . It resolved my error.

    Ashwini

  • Thank you. This simple fix has made my day

  • thanks it helps :)

  • Thanks. You saved me at least  a couple of hours:)

  • thank you!!!!It works!!

  • Thank you so much.. solved the problem... :)

Page 1 of 1 (7 items)