Apr 30, 2008

Debugging Win Service

For debugging a Startup of Windows Service add the call to the Method Debugger.Launch or Debugger.Break. This call can be placed in the Constructor of the Service.cs or in the first line of the OnStart() method.

Calling Debugger.Launch() or Debugger.Break() in your code allow you to debug such problems.

For debugging an already running WindowService, simply attach the Debugger to to an existing process using "Debug\Attach to Process" menu item in VS 2005/VS 2008.

Visual Linq is a tool to visually create your Linq to SQL queries: http://code.msdn.microsoft.com/vlinq

A Primer on WCF :

It is all about Service Contracts, Operation Contracts, Data Contracts and Fault Contracts and other type of Contracts

Contracts usually enforced on Interfaces and the Classes then implement these interfaces.

If Service Contract, Operation Contract attributes are applied to classes then we have an additional advantage that the methods can be marked private and can still be accessed by WCF clients.

DataContracts are used to create .NET objects that can be sent to/fro between the client and the WCF Service. thus the DataMember attribute tells the runtime which properties need to be serialized/deserialized by the framework before being passed onto the network.

We dont need DataContracts for Intrinsic objects like Int32, string etc since they are natively serializable

FaultContracts can be applied to methods and can be used by the Client to determine what exceptions occurred at the server during processing of the request. Thus .NET exceptions are converted to FaultExceptions which are then sent over the wire as SOAP faults and then the client can reconstruct them to extract the Fault Detail from the FaultException

A good introduction to WCF can be found here: David Chappell's intro to WCF

Bindings and endpoints form the heart of WCF, we can have different kinds of bindings,

  • BasicHTTPBinding which allows Http and HTTPS access.
  • WSHttpBinding which adds the WS specifications to the binding to provide for reliability, transactions, security and other features.
  • WSDualHttpBinding: use this for two-way communication between client and service, only HTTP is supported
  • FederatedBinding: which means that if authenticated by one of the services, then the same ticket can be used to authenticate the client to other WCF/Java services
  • NETTCPBinding : used when communicating using TCP protocol as the transport
  • NamedPipeBinding: used within the local machine for inter process communication on the same machine.

Endpoints define how the service can be accessed by the client. Each WCF Service exposes endpoints to clients to publicize their services. Specify a different endpoint for each binding used by your service, thus the same machine can expose the service over HTTP and TCP using basicHttpBinding and NetTcpBinding respoectively and thus exposing endpoints for each of them. Endpoints consist of address, behavior etc

John Sharp's WCF Step by Step from Microsoft Press is an excellent book to get started.

kick it on DotNetKicks.com

Apr 6, 2008

Get back almost 1GB of free disk space after Vista SP1 installation

If you have installed SP1 of Vista you certainly recognized that your drive lost around 1Gb of free space.

The solution is to use a tool that comes with the SP1 to recover your free space at the price of not being able to come back and uninstall the SP1.

This tool is vsp1cln.exe that you can run like this:


kick it on DotNetKicks.com