Thursday, March 18, 2010

Enterprise Library 5.0 Beta1

I would like to share the way to configure the logging application block with a sample web application to log the errors to the Event Listener and to a log file.

Once you have installed the Enterprise Library 5.0 Beta1 into your machine make sure to make it as strong named it by applying a key using the Visual Studio.

After that add a reference to the logging application block assembly Microsoft.Practices.EnterpriseLibrary.Logging.dll in your project.

the next step is to configure the Logging Application Block using the Enterprise Library tool located under Program Files => Microsoft patterns & practices => Enterprise Library 5.0 Beta 1 - February 2010 => Enterprise Library Configuration.


so the Configuration tool open like below :


Open your web.conf or app.conf file using the above tool as below:


by default it will list you the Application Settings and the Database settings and it does not contain anything and if you need to configure something on that feel free to add those values.


As we need to test the logging application blocks, please add the Logging Application Blocks by clicking Blocks => Add Logging Settings as below.


so it will lists you the settings as below :


Enter a name for your Event Log listener as below:


Under All Events settings make sure to add your recently created listener into the list as below:


Click the “+” sign next to the Logging Target Listeners and select Add Logging Target Listeners => Add Flat File Trace Listener.


Once you add the Flat File Listener the configuration tool will looks like below:


After that select the log file name to log the events and the Formatter as Text Formatter.



Upon making the above settings make sure to add the above listener to the All Events settings as below :


Upon following the above steps write the following code in C# and test the solution, you will find the entries written upon in the Event Log and the Log file which you did specified in the above step :

LogEntry logEntry = new LogEntry();

logEntry.Severity = System.Diagnostics.TraceEventType.Information;
logEntry.ProcessName = "Section XYZ from your project";
logEntry.Title = "Testing";
logEntry.Message = string.Format("Your Message");
logEntry.TimeStamp = DateTime.Now; Logger.Write(logEntry);
catch (Exception ex)

Wednesday, March 17, 2010

Consuming a Web Reference in a class library (C#/.NET) – VS 2008

when you tried to add a web reference to a Class Library in VS 2008, by default it will add a Service Reference (WCF). I have seen this option only in VS 2008 and not in VS 2005. If you need to add a Web Reference then at the time of adding a Service Reference, click the Advanced button as depicted below :


After that click the Add Web Reference as below:


after that you will be prompted with the usual add web reference dialog.


Sunday, March 14, 2010

Setup says VS Integrated Shell 2010 ENU installed when uninstalled, Grrrr!!!

I came across a situation where i had to remove the Team Explorer version 2010 Beta1 from my machine. I have uninstalled it via Uninstall option from the Programs and Features. When i tried to install TFS 2010 RC Team Explorer setup it says “VS Integrated Shell 2010 ENU” exists and have to remove. I did the uninstallation and restarted the machine even. Nothing happened and when i ran the installation it prompts me again saying that “VS Integrated Shell 2010 ENU” already exists. I checked the Programs and Features and it was not there. :(

I was something like this :


finally found the solution.

simply run this command :

msiexec /uninstall {874D5E2B-AACE-303A-B3EC-2563E071473E}

lets we dig little bit deeper in to the above command.

Initially you have to to do is to use msiinv.exe (thanks to Aaron Stebner’s to exposing the tool) tool to see if MSI thinks the integrated shell is installed or not. So from that tool it will lists all the installed programs and under that list you can see this ghost “VS Integrated Shell 2010 shell ENU” still exists in the list.

what you have to do is just note down the Product Code and use the same code to execute the above command.

VS2008 Professional connecting to TFS 2010 RC on Windows Server 2008

Assuming that you have already installed VS 2008 professional edition (no problem eventhough you have installed the VS 2008 SP1 because anyhow you are going run it again) in your machine and in your machine TFS 2010 RC is installed and configured successfully.

Please follow the following steps as its :

  1. You have to install Team Explorer 2008 over your VS2008 Professional SP1.
  2. You need to reinstall VS2008SP1 to update team explorer.
  3. After that you have to install Visual Studio Team System 2008 Service Pack 1 Forward Compatibility Update for Team Foundation Server 2010 (Installer) from this link.
  4. When you connect from VS2008, you need to enter the full URL (ex: :/tfs">https://<MyServer>:<port>/tfs)


Team Foundation Server 2010 RC Installation

After a lengthy hard work we were able to install and configure the Team Foundation Server 2010 RC on Windows 2008 R2. Eventhough the installation and the configuration is easy we had some trouble with the DNS naming of the host machine (thanks to Usman – Team Lead to identifying that issue).

kick off the installation by clicking the setup file and follow the screens just clicking the next button.




After the completion of the installation its time to configure the TFS 2010.



In this situation you have to enter a authenticated user who has the administrator rights in the domain.

image clip_image008

from the following screen you can double check all your entries are valid or not by clicking the Verify button. Its one of the best feature in this configuration wizard rather messing up the things after the completion of the installation.

image clip_image014





Thursday, March 11, 2010

Missing Application Pools Folder in IIS - Windows Server 2003

to get the application pools back to the IIS please follow the steps as mentioned below:

1. In IIS Manager, expand the local computer, right-click Web Sites, and then click Properties.
2. Click the Service tab, clear the Run WWW service in IIS 5.0 isolation mode check box, and then click OK.
3. To start the WWW service, click Yes when asked if you want to restart IIS now.

WCF and Web service

Features Web Service WCF

It can be hosted in IIS

It can be hosted in IIS, windows activation service, Self-hosting, Windows service

[WebService] attribute has to be added to the class

[ServiceContract] attribute has to be added to the class

Model [WebMethod] attribute represents the method exposed to client [OperationContract] attribute represents the method exposed to client
Operation One-way, Request- Response are the different operations supported in web service One-Way, Request-Response, Duplex are different type of operations supported in WCF
XML System.Xml.serialization name space is used for serialization System.Runtime.Serialization namespace is used for serialization
Encoding XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom

XML 1.0, MTOM, Binary, Custom

Transports Can be accessed through HTTP, TCP, Custom Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom


Security, Reliable messaging, Transactions

State state less

can manage states

Installing a SQL Server 2008 named instance – Windows Server 2008 R2

Run the setup from your SQL Server 2008 CD



Click Installation tab and click New SQL Server Stand Alone installation or add features to an existing installation.







Accept the licensing terms.



Give a name to the SQL Server instance.




i am not going to install this particular instance in mixed mode hence i have selected the windows authentication mode. Setup wont allow you to go to next step unless if you didn't specify a administrator account. I have added the current user credential as one of the administrator account for the SQL Server.