Archives for the '.NET' Category

Invoking a post-build batch file in TFS 2010

The scenario: you are using TFS 2010 as your build server, and you would like to deploy files to a remote server upon successful build by invoking a batch file.
Do note that the following steps work great in conjunction with Visual Studio T4 Templates, whereby multiple .config files (e.g. Web.Dev.config, Web.Test.config) can be generated from […]

4 June 2012 | .NET | 6 Comments

Exception-handling wrappers for Task.ContinueWith()

The .NET 4 Task Parallel Library is great because you can specify continuations for new threads:

private Task<WebResponse> GetWebResponseAsync(string url)
var webRequest = WebRequest.Create(url);
return Task.Factory.FromAsync<WebResponse>(

public […]

28 May 2012 | .NET, C# | 3 Comments

Calling an Oracle stored procedure using NHibernate

The stored procedure must have an out sys_refcursor parameter as the first argument.
Tested with NHibernate 2.1.2 and Oracle 11g.
Needs Oracle.DataAccess (not System.Data.OracleClient). Tested with Oracle.DataAccess AMD64.

NHibernate config:

<hibernate-configuration xmlns=”urn:nhibernate-configuration-2.2″>
<property name=”connection.driver_class”>

NHibernate mapping:

<hibernate-mapping xmlns=”urn:nhibernate-mapping-2.2″ assembly=”SampleProject” namespace=”SampleProject”>
<sql-query name=”GetEmployeesByDepartmentId”>

17 January 2012 | .NET, C# | 4 Comments

LINQPad – a worthy successor to Snippet Compiler

In 2009 I blogged about how Snippet Compiler allows us to test out C# code without having to create a project in Visual Studio just for that. Now there’s something better: LINQPad. Don’t be misled by its name; it’s not just for LINQ, it can run any C#, VB, or even SQL code. I particularly […]

5 August 2011 | .NET, C#, Applications | No Comments

Implementing the right-click context menu in Silverlight 4

Download and install Silverlight 4 Toolkit - April 2010.
In your Silverlight 4 project, add references to:


In your UserControl XAML, add the following to the LayoutRoot grid opening tag: MouseRightButtonDown=”LayoutRoot_MouseRightButtonDown” MouseRightButtonUp=”LayoutRoot_MouseRightButtonUp”
In the codebehind:

using System.Windows.Controls;

private void LayoutRoot_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
e.Handled = true;

private void LayoutRoot_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
var contextMenu = […]

16 November 2010 | Silverlight, .NET | 2 Comments