21 April, 2010

How to Use Visual Studio Profiler

Recently I came to know that there is a inbuilt profiler in Visual Studio 2008, with which we can know the performance of our application. This can be started from VS Analyze tab.
Here are the simple steps to use this profiler.
  1. Open the project in visual studio and go to analyze tab -> profiler -> new performance session
  2. Performance Explorer will be added to the application. In that explorer click Launch performance wizard.
  3. A wizard will be opened with the application selected by default and three simple steps to set up new performance target
  4. Click on Launch with profiling button on the Performance Explorer. This will run the application, just like we run in debug mode.
  5. Go through the scenario, in which you want to know the performance one by one. But going for One at a time is suggestible.
  6. Once the scenario ends, Click on Stop profiler icon. This will automatically generates a report.
  7. Report provides various view of data. We can use functions view to check which functions taking so much time.
Using this profiler is very simple. But understanding the report generated by this is a bit difficult and needs some basic information on what is shown in the report. More details can be found at http://msdn.microsoft.com/en-us/magazine/cc337887.aspx

extendedProtectionPolicy tag problem: Workaround

When one use Windows7 to generate a WCF configuration file/ proxy that will generate some extra lines of code which will cause the problems in running the application.
The extra lines generated are not supported in Silverlight/WPF environment.
Those lines will look like
    <extendedprotectionpolicy policyenforcement="Never" />
There are some limitations for silverlight & WPF to use custombinding. You can read an article related to this at

Those extra tags can be deleted or commented to run the application.

17 April, 2010

Sys.InvalidOperationException: InitializeError Error #2104

I started development in silverlight recently. When everything is installed, i just started with a test application and on running the site i got the following exception.

Microsoft JScript runtime error: Sys.InvalidOperationException: InitializeError error #2104 in control 'Xaml1': Could not download the Silverlight application. Check web server settings

I am surprised to see this error as all the required things are installed. But I missed one small thing. That is to add silverlight application MIME type to the web server(IIS). After adding this MIME type, my application run without any error.

Steps to add MIME type in IIS6:
1) Goto the silverlight web application/ website properties.
2) Open HTTP Headers Tab and find MIME types region.
3) Click MIME Type button and add new MIME type
4) Type .xap and application/x-silverlight-app as extension and MIME types respectively.
5) Save your settings. This will add silverlight mime type to the sever, so that our application run without any error.

07 April, 2010

Linq: Query for multiple join conditions in Linq to SQL

This is common to join a table with another on multiple conditions, Like

Select * from Customer c
Join Invoice i on c.CustomerID = i.CustomerID and c.CustomerTypeID = i.CustomerTypeID

I need to write a Linq to SQL query for the same scenario. But the syntax for this query is a bit different to expect. The Linq query is as follows:

From c in DataContext.Customers
Join i in DataContext.Invoices on new { c.CustomerID, c.CustomerTypeID } equals new { i.CustomerID, i.CustomerTypeID }

*DataContext in the above query should be replaced with actual datacontext name.