Web Platform Installer 3.0

I have been using the Microsoft Web Platform Installer or PI for a while now. It’s a great handy tool for ensuring that I have all the latest bits of Web platform tools like MVC, Web Matrix are installed. One of the other thing I like about Web Platform Installer is that the tool can self update itself. When a new version of the tool is released, it shows a dialog box to the user to install the latest version of the tool.

Recently I installed the PI version 3.0


Apart from the Spotlight tab showing the recent released, as usual the Products tab shows all the products. It can also the filtered into different category of downloads like Server, Framework, Tools etc.


I hope some day Microsoft would release a same type of tool for Windows developers also!


File.GetLastWriteTime does not throw an exception if the file does not exist

Lately I have been working in performance engineering and improvement of a big and complex enterprise class product for financial market. Typical to any product or app for financial market, this product also has to deal with high volume of data – so every second (actually millisecond) counts. While profiling the App with Ants Profiler I saw that one of the methods which is costly is spending considerable amount of time in .NET API File.Exists method. The method actually gets the last write time of a file using File.GetLastWriteTime(filePath) but before that it checks whether the file exists through File.Exists. The reason is to make sure to call File.GetLastWriteTime only when File exists so that it does not throw exception. Following was the code used –


So as I started looking I thought to check whether the assumption of using File.Exists is correct. To my surprise I found in MSDN that File.GetLastWriteTime does not throw an exception in case the file does not exist.

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

So I re-wrote the code in the following way and was able to remove the call to File.Exists method which was costly –


Note that I had to compare the time in UTC as File.GetLastWriteTime returns 12:00 midnight, January 1, 1601 A.D. in UTC time.

Over the next few blog entries I would share some more performance improvement tricks. Happy Profiling!

ASP.NET 4 Chart Control

One of the best new feature of ASP.NET 4.0 Web Form (yes it’s still alive) is the new Chart control. There have been a need for a Chart control for a long time – from version 1.0. Folks have used custom controls from various sources or written their own one. Now in ASP.NET 4.0 Microsoft have introduced a Chart control ultimately. This could be used in ASP.NET MVC also apart from Web Forms.

The Chart control provides all different type of charts like Column, Bar, Line, Area, Pie, Doughnut (to name a few). Following is an example of Chart with chart type Column.


To set up a basic chart control you have to set a few properties like XValueMember and  YValueMembers. In the example I have displayed the Total Sales figure for few cities. Following is the page markup –


As you can see I’ve set XValueMemeber to City and YValueMembers to TotalSales – both of them are properties in my DTO –


The chart type could be set in markup or through code for the series –


chtSalesData.Series[“Series1”].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;

image         image   

image         image

Web Browser Control in Silverlight 4

I have been playing with Silverlight 4 for a while now. I know it’s too late probably to talk about some of the new features of Silverlight 4 since Scott Gu already have announced Silverlight 5 to be made available in early 2011, but I have been rather quite busy with my day job Smile. Also I left Target India and joined Misys Software as Senior Architect – so as a whole on the professional front I have been little busy lately. Anyway, it never too late.

Among the many features included newly in Silverlight 4, max importance have been on enabling and adding features that would help use Silverlight for Business Application Development specially of Enterprise scale similar to other UI technologies like WPF, Win Forms (I know people are still using it for new enterprise business apps), ASP.NET Web Forms and ASP.NET MVC (both with and without Ajax).

Silverlight 4 now supports Web Browser control that was long present in Win Forms. The Web Browser control can load a HTML page – it’s truly a mini IE. Note that Web Browser control can show content only in Full Screen mode. When it’s running within a browser embedded it does not display any content –


Since Sliverlight 4 has started officially supporting Google Chrome (though earlier also it used to work) I thought of using Chrome for this post.

So to use Web Browser control, Silverlight 4 must have to run out of browser. To load a page/HTML content or any browsable content (that browser can interpret like ASP.NET web page), use the Source property of the Web Browser control –

<WebBrowser x:Name=”webBrowser” Source=”https://caniruddha.wordpress.com/” /> – XAML
webBrowser.Source = https://caniruddha.wordpress.com/; – code

You can also use the Navigate and NavigateToString methods. While Navigate accepts a sting for URL, NavigateToString accepts a Uri object –

webBrowser.Navigate(new Uri(“https://caniruddha.wordpress.com/”));


.NET Profiles in .NET 4 and VS 2010

As I have mentioned earlier in my last blog post, .NET 3.5 SP1 first had the concept called Profiles. In .NET 3.5 SP1 it was possible to build an app for Client Profile. The idea is to create subset of the whole .NET Framework, which is very big for easier install, maintenance and less memory footprint. Since Client Apps really need a subset of whole .NET Framework, .NET 3.5 Client Profile contains only client specific libraries like ASP.NET, WPF, CLR and WinForms. Libraries like ASP.NET or LINQ were not included as they are not required for Client Apps.

Now in .NET 4, there is one more profile available – called Server Core Profile. Server Core Profile is a subset of the .NET framework for server applications. It can run server oriented applications like ASP.NET and WCF.


As you can guess, Server Core profile does not contain Client UI specific libraries like WPF and WinForms. So if you create a WPF or WinForms app and change the Target Framework (in Project properties dialog) to .NET Framework 3.5 Server Profile, certain dlls (from WPF or WinForms) would be missing and you would get an error while compiling the app.



Now as you can see, there isn’t a Server profile available for .NET Framework 4 in Beta 2. You can expect to see that when .NET 4 (and VS 2010) is finally released by Microsoft this year.


.NET Framework Client Profile – new in .NET 3.5 SP1

.NET Framework 3.5 SP1 (Service Pack 1) comes with a new deployment feature called “.NET Framework Client Profile”. It provides a new setup installer that enables a smaller (27 MB), faster and simpler installation experience for .NET client applications on machines that do not already have the .NET Framework installed. It’s a subset of assemblies already contained within .NET Framework 3.5 Service Pack 1.

Client Profile contains the parts of .NET Framework that is typically used in .NET client apps –

  • Common Language Runtime (CLR)
  • ClickOnce
  • Windows Forms
  • Windows Presentation Foundation (WPF)
  • Windows Communication Foundation (WCF)

To show how Client Profile works let’s create a WPF client app (you can also create a Win Forms app). Open the project property window and navigate to Application tab.

Check the “Client-only Framework subset” checkbox  as shown below – (by default it’s unchecked).


That’s all that you need to do to use “Cleint Profile”. Once this is checked, app.config file is added in the project. Open the app.config file and you would find the following entry –

<?xml version="1.0"?>



    <supportedRuntime version="v2.0.50727" sku="Client"/>



The supportedRuntime element specifies which versions of the common language runtime the application supports. At runtime, the framework runtime will check the contents of the file, if the sku="Client" declaration is not found, the runtime will assume that this application requires the full .NET Framework and prompt the end-user to install the full .NET Framework.

Now to test how Visual Studio behaves if a .NET dll/asssmebly that’s not part of Client Profile is referenced in the project, we will add a server only .NET assembly.

So we added System.Data.Linq as project reference (System.Data.Linq contains classes of LINQ to SQL). Once the dll reference is added, build the project. You would notice two thing –

The dll just added (System.Data.Linq) is shown with missing reference (exclamation icon).

A warning mentioning System.Data.Linq is not part of Client Framework subset is shown by Visual Studio.


So for using Client Profile or Client Framework subset you should use only the dlls that are part of client framework subset.

Here’re few good links –