Follow by Email

Thursday, December 29, 2011

Create Nuget Package with powershell script


There are so many blogs available to creating nuget package but i would like to go in more details with powershell script option in that.

Use GUI tool

Using commnad lines ( ) you can create whole package however better way is to use GUI (Nuget Package Explorer)

Please look below link & follow step

Know about Directory structure

Directory structure of Nuget Package as per

  • tools – contains Powershell scripts
  • lib – contains assemblies (dlls)
  • content – contains files to be added on root path

Alter web.config or app.config and Source

If you want to add some settings in configuration file then it is also possible using .tranform
Just add web.config or app.config in \content folder with .tranform extension e.g.

Using Powershell Script

Now if you want some manipulation with files in project then you have to add Powershell Script
under \tool folder , following 3 types files you can add for that , read about in more details at here

    • Init.ps1 runs the first time a package is installed in a solution.
  • Install.ps1 runs when a package is installed in a project.
  • Uninstall.ps1 runs every time a package is uninstalled.

Example to change property value of Project's Item & dispaly popup Message

Here i am going to create install.ps1 and add powsershell script to change property of Test.exe file
Copy To Output Directory = Copy Always

$project.ProjectItems.Item("Test.exe").Properties.Item("CopyToOutputDirectory").Value = 1

also add script to open popup at last as per shown in below figs.

Monday, December 26, 2011

Handle chart rendering on multiple instance of Azure webrole application

If you would like to know how chart rendering occurs with different ways in then this link is great one.

Generally when we add graph , at that time in web.config handlers will be added automatically as per below

<remove name="ChartImageHandler"/>
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>

and to store graph images in folder we need to put app-setting as per below
<add key="ChartImageHandler" value="deleteAfterServicing=false;Storage=file;Timeout=20;URL=~/TempCharts/; />"<validation validateIntegratedModeConfiguration="false"/>

in this case graph data point will be plotted and image will generated and store that in temp folder (as per appsetting)
and on request that image will be displayed on page .

Now this will work well in window azure up to 1 instance but when you will make more then 1 instance at that time sometimes graph will be empy. why?

because if one request store that image in first server of stack then another request want that graph from different server of stack and it can not able to find there!

So how we can handle this issue on multiple instance

simple solution is instead of temp location we need to use blob storage  provided by Azure.

generally chart control will use custom charthanlder for handling to store images of chart so we need to make custom chart handler that will store chart images in blob storage and from there it will be serve in all instances.

Just code your custom handler as per below

public class ChartImageHandler : IChartStorageHandler
CloudStorageAccount account;
CloudBlobClient client;
CloudBlobContainer ImageContainer;

public ChartImageHandler()
//Here you get the container to the CloudStorageAccount object
//The proper way to do this is with:
//account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
//this is the Dirty way...

account = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=<youraccountstorage>;AccountKey=<yourkey>");
client = account.CreateCloudBlobClient();

//The name of the image container is totatally up to you
ImageContainer = client.GetContainerReference("images");
//if it may not exist, you can use this call to create it....
#region IChartStorageHandler Members

public void Delete(string key)
CloudBlob image = ImageContainer.GetBlobReference(key);

public bool Exists(string key)
CloudBlob image = ImageContainer.GetBlobReference(key);
return true;
catch (StorageClientException e)
if (e.ErrorCode == StorageErrorCode.ResourceNotFound)
return false;

public byte[] Load(string key)
//sometimes load gets called before save is done

CloudBlob image = ImageContainer.GetBlobReference(key);
byte[] imageArray;
imageArray = image.DownloadByteArray();
catch (Exception e)
imageArray = image.DownloadByteArray();

return imageArray;

public void Save(string key, byte[] data)
CloudBlob image = ImageContainer.GetBlobReference(key);

you need to add reference of this dll found in window azure SdK at C:\Program Files\Windows Azure SDK\v1.3\ref


and in web.config just assign that handler in appsetting as per below

<add key="ChartImageHandler" value="deleteAfterServicing=false;Storage=file;Timeout=20;URL=~/TempCharts/;handler=MyApp.MyChartHandler.ChartImageHandler, MyApp;" />

Friday, December 23, 2011

Session state in Window Azure using caching

In my previous post , I have talked about different ways to maintain session state in window azure.
From there the best way to maintain session state in window azure is by using appfabric caching, so i am going to discuss it here in details.

1) Create a Cache in Windows Azure

Open management portal , click on servicebus & caching option as per shown in fig-1.

Expand services and click caching , create new namespace as per shown in below fig.

Select service (here cache) add namesapce, location and subscription as per shown in fig

click to view client configuration file.

2) Prepare Visual Studio to Use Caching for Windows Azure

Verify that the target framework version is .NET Framework 2.0 or higher (non-client profile).

open web.config copy portion of configsection , datacacheclient in web.config,

copy Sessionstate section under system.web

Related Links


Wednesday, December 21, 2011

How to maintain session state in Window Azure

In ASP.NET there is concept of a session which is maintained from the user’s first request to their last request for visit of the web site. By default, ASP.NET session is maintained in the RAM of the running web server.

However Window Azure is statless!, web role haven't any local storage.

If only one instance in webrole then usaul session will work but when you make more then one instance then sesion will not work because at any time trafic will be moved to different instance the data center.

generally in web.config session state defined as below

<sessionState timeout="20" mode="InProc"></sessionState>

that is InProc session state maintain in process and will remove after 20 minutes

In Window azure you can maitain session state by following ways

1) By SQL Azure

you can use sql azure database to store session values.

web.config Change

<sessionState mode="SQLServer"


2) By Table Storage

you can use storage (table storage) availbale on window azure 

web.config Change

<sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
<add name="TableStorageSessionStateProvider"
type ="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider"/>


Download aspprovider from here

3) By AppFabric Caching

You can use appfbric  caching to store session values

web.config Change

<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
<!-- specify the named cache for session data -->


Thursday, December 15, 2011

Explore ASP.NET - AutoEventWireUp


If you are developer then may be you know this term -"AutoEventWireUp"

I would like to write about this because many developers don't know about it as it will be added automatically when you create any page in

But it is basic fundamental thing every developer should know about it!

If you ask question yourself why all page_event will be call automatically?

then "AutoEventWireUp" can give you answer about that.

As per msdn link

"If the AutoEventWireup attribute of the @ Page directive is set to true, page events are automatically bound to methods that use the naming convention of Page_event, such as Page_Load and Page_Init."

1) By default It is true
2) If you make It false then page_event will not call automatically
for that you need handled that event explicitly
        protected override void OnInit(EventArgs e)
            this.Load += Page_Load;

To know more about it look ASP.NET Web Server Control Event Model

An another product by google - google currents

Finally Google launched it's another product in competition with flip board & amazon kindle

This is attempt of Google to give you content in magazine format.

Google Currents is integrated with Google+ so users can share articles or videos they’ve enjoyed with their circles.

Download Google currents for android and apple devices from here.

See the introduction video on You Tube

If you would like to publish your content then get start from here

Related Links

Saturday, December 10, 2011

Why Mark Zuckerberg is a great IT Leader?

Fist question raised in some people mind who is Mark Zuckerberg ? but when you ask about Facebook then every people says that I am on Facebook !
So Mark Zukerberg is founder of Facebook and  youngest billionaire of the world and person of the year 2010 by Times magazine. Many people also watched movie "The Social Network" on this geek guy.

You should have look details of this young guy on Wikipedia here

Why I believe that he is Great IT leader , there are many reason behind this....

A great leader has big and great vision - You can see in Mark and Facebook 
A great leader make prosperous life of his followers - You like to follow it
A great leader can never stop learning and continue on their path without looking past and create history for futureA True Entrepreneur
A great leader encourage people to make change in this world and to reach new heights.
A great leader remain always motivated and motivate people around him.
A great leader never worry about giant competitors when he start their business. (Mark had started development of Facebook when he was studying and goggle and Microsoft were giant IT company at that time)
A great leader always make great smile.   :)

The most amazing thing is that he has make $80 billions on just one site!!

Great quotes by Mark Zukerberg
"I started the site when I was 19. I didn't know much about business back then."

"I think a simple rule of business is, if you do the things that are easier first, then you can actually make a lot of progress."

Read more @ here

And in the last see him with  The Most powerful man of the world US president Obama as Mark also stand at 9th position.

Sunday, December 4, 2011

World is changing let’s look at Future of work


Population is increasing at tremendously and everyone is busy in study to make their career, to get good job, to make money... on the other hand economist says that 2nd crisis will be soon..

Non-technical people say that because of technology unemployment is increasing but no one can stop this growth you have to change with world that is only option :)

This will never end if technology is changing every day then it will create new opportunity in work , to earn money just you need to find ways and implement it and you will be winner !

Just look at below video , Future of Work - it's Awesome!

Just try to change you as world is changing now