WebMethodAttribute.CacheDuration Property

When creating a web service based data abstraction layer / façade, if you have methods that return “type” tables such as counties/states or employee types; caching the response to these requests improves performance by reducing db lookups for data that rarely changes. Simply apply the CacheDuraction property to the WebMethod attribute specifying the number of [...]

Enterprise Library Application Block Logging

The Enterprise Library Application Block has been recently released, as a user of the existing Logging Application Block (LAB) with cross web service request tracing it is a little disappointing to see no mention (as yet) of similar support in the new Logging and Instrumentation Application Block. As I’m currently mid-way through a development which uses [...]

Logging Application Block Log Levels

LAB LogLevels (summarized from Logging Application Block documentation © 2003 Microsoft Corporation http://www.microsoft.com) None (level 0)No logging - not advised for production. Always (level 1)Default for system and all events that are raised without specifying the logging level. Eg, audit events or metering events can specify this log level. Error (level 2)Application running in production. All errors and [...]

Windows Service Path Not Found Exception

If you get an invalid path / path not found error when trying to start a .net windows service or right-click properties for it check any PerformanceCounterInstaller(s) and ensure their CategoryName is not the same as the ServiceInstaller’s ServiceName. Why? Seems to be something to do with the registry entries created/deleted when these installers run. [...]

Catching Errors in Windows Services

In Windows Service put a try..catch around InitializeComponent in New constructor to catch and handle any init problems, especially when using components that have external dependencies such as performance counters and message queues. TryInitializeComponent()Catch ex As Exception‘ Log or handle event here‘ if you want to inform the Windows Service Control Manager‘ that the service has [...]

Logging Application Block: Event Types Quick List

A quick list of some event types you can raise using the Logging Application Block (http://microsoft.com) AdminMessageEvent AuditMessageEvent AuditOperationEvent ErrorMessageEvent ExternalErrorMessageEvent InternalErrorMessageEvent MeteringEvent TraceCallEnterEvent TraceCallReturnEvent TraceDatabaseCommandEvent TraceExternalCallEvent TraceExternalReturnEvent TraceMessageEvent

MSMQ Intermittent Exceptions

Intermittent errors such as following when using MSMQ .NET (1.1) Index was outside the bounds of the arraySpecified cast is not valid System.Messaging.Interop.MessagePropertyVariants.Lockget_Label msmq exceptionIndex was outside the bounds of the array MessageQueue.Send These can occur randomly if you have 1 instance of message queue component and multiple references to it (for example in multiple threads) with [...]

Creating MSMQ Exception

In testing you might want to throw a manual MessageQueueingException to test the functionality of your exception handling. As it’s not possible to create an exception object the following can be used to throw an exception: ReceiveById(”this is a made up id to force an exception”) As long as no message exists that matches this you will [...]