29 December 2010

Advanced C# Windows Service Installation

Click this link, to download source code.
Today, I'm going to show you how to efficiently create Windows Services and deployment projects, using C# in Visual Studio 2010.  These techniques illustrate methods of centralizing key information about the services included in the project, to prevent typos and other mistakes attributed to setting similar properties in decentralized locations.

This example is especially useful for projects that contain several services that use common code bases.  For example, I have a service suite that monitors several FTP drop directories on a server.  Each watcher performs different, custom actions; but, 90-95% of the code is common to all services.  For this and other reasons not discussed here, it makes sense to simply package all services in one project.  The more popular alternative is to create a common library, install to GAC, and create individual service solutions.

The bottom line is that I wanted to simplify management and deployment.  To simplify service registration, I created a "ServiceInfo" class attribute into which all service information is entered, instead of mucking about in several ProjectInstaller files.  View the full article, to get source code and a complete walk-through.

UPDATE 13 MAR 2012: I updated the code sections, to use formatted HTML, instead of using JavaScript code coloring.  The code was formatted a bit, for fit, and to make the LINQ more efficient.  Therefore, the code in the download won't be exactly the same, but it works.

16 December 2010

How To Create a C# Windows Service Application

Today, I wrote a Windows service application.  Because part of my day job is teaching C# and .NET, I was inspired to write a "how to" document.  The Walkthrough: Creating a Windows Service Application in the Component Designer article found on MSDN is quite helpful, if you know your way around C# and .NET.  Anyone who doesn't understand C# and .NET enough to make short work of the document arguably has no business writing a service; but, we all have to learn sometime.

UPDATED 29 MAY 2012 - Revised several areas for clarity and simplification, and updated formatting.

06 December 2010

Reporting Services Item Templates

Download source code
Download binary (.EXE)

Problem

Last week, I needed to rebuild a couple of reports on SQL Server 2005 Reporting Services, and found I need item template support in Microsoft reports.  How to use item templates in Reporting Services?  Well, in short, you can't.