Configuring Microsoft Team Foundation Server 2012

Filed in .Net Leave a comment

Today I have configured Microsoft Team Foundation Server 2012 for one of my newly started VS project. Looks promising product for every stakeholder of the project. My focus is mainly on code maintainability, task assignment and its management. Below are some useful links.

Using TFS

Optimize your folder names

Set Up Your Dev Machine and Start Using Version Control

Add Files to the Server or Add Project/ Solution to TFS

Check In Your Work to the Team’s Codebase

Resolve File Conflicts

how to get row index in DragDrop event of datagridview

Filed in .Net Leave a comment

exception logging block not logging with correct datetime

Filed in .Net Leave a comment

In app.config change {timestamp} to {timestamp(local)}

Activation error occurred while trying to get instance of type Database, key “KEYNAME”

Filed in .Net 2 Comments

In my case  providerName=”System.Data.SqlClient” tag is missing from connection string

<add name=”KEYNAME” connectionString=”Data Source=.\SQLEXPRESSR2;Initial Catalog=DBNAME;Integrated Security=False; User ID=userid;Password=password; Max Pool Size=500″ providerName=”System.Data.SqlClient“/>

Below is from more error log

Type :Microsoft.Practices.ServiceLocation.ActivationException
Original Message : Activation error occured while trying to get instance of type Database, key “<KEYNAME>”
Source :Microsoft.Practices.ServiceLocation
Stack Trace : at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key)
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.InnerCreateDatabase(String name)
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(String name)

Inner Exception Message is :Resolution of the dependency failed, type = “Microsoft.Practices.EnterpriseLibrary.Data.Database”, name = “<KEYNAME>”.
Exception occurred while: while resolving.
Exception is: InvalidOperationException – The type Database cannot be constructed. You must configure the container to supply this value.
At the time of the exception, the container was:

Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,<KEYNAME>

Inner Exception Stack Trace is : at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
at Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)

Make a new column in datatable c# using existing columns or hardcode values, using expression

Filed in .Net Leave a comment

Merge two or more columns in c# datatable

ds.Tables[1].Columns.Add(“NEWCOLUMNNAME”, typeof(System.String), “COL1+ ‘-’ + COL2″);

You can make any complex sql expression.

Gridview select all checkbox, row color change on selection/hover, row delete client side

Filed in .Net Leave a comment

Set Hex code of color in c#

Filed in .Net Leave a comment

e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(“#CEFFCE”);

Calling a custom function in gridview template column

Filed in .Net Leave a comment

Text=’<%# MakeFullName(Convert.ToString(Eval(“FirstName”)),Convert.ToString(Eval(“LastName”))) %>’

enable disable validators on drop down selection change client side

Filed in .Net 1 Comment

JavaScript function:

function setValidations() {

var ddlst = document.getElementById(“<%=ddlPiggyback.ClientID%>”);

var Text = ddlst.options[ddlst.selectedIndex].text;

if (Text == ’0′) {

ValidatorEnable(document.getElementById(“<%=rfvPiggybackComments.ClientID%>”), false);


else {

ValidatorEnable(document.getElementById(“<%=rfvPiggybackComments.ClientID%>”), true);



In drop down (aspx side)

<asp:DropDownList ID=”ddlPiggyback” runat=”server” onchange=”setValidations();”>





Convert string value to enum

Filed in .Net Leave a comment

(Enums.RequestType)Enum.Parse(typeof(Enums.RequestType), rblRequestType.SelectedItem.Text)