Sometimes your ERRORLOG is peppered with messages complaining about the service SqlQueryNotificationService-<guid> not existing or query notification dialogs being closed because they received an error message with the text Remote service has been dropped. I have blogged about this problem before: http://rusanu.com/2007/11/10/when-it-rains-it-pours/. Unfortunately this problem was not under your control as an administrator nor as a developer. It is caused by the way the SqlDependency component of ADO.Net deploys the temporary service, queue and procedure needed for its functioning. The problem could be caused by your application calling SqlDependency.Stop inadvertently but also by simple timing problems: http://rusanu.com/2008/01/04/sqldependencyonchange-callback-timing/.
Good news: Microsoft has shipped a fix for this issue: http://support.microsoft.com/kb/958006. According to the knowledge base article you need to install the following Cumulative Update depending on your current version of SQL Server deployed:
- For SQL Server 2005 SP2 you need CU 10.
- For SQL Server 2005 SP3 you need CU 1.
- For SQL Server 2008 you need CU 2.
If you have SQL Server 2008 SP1 deployed you do not need to install any fix because the issue is fixed in SP1 for 2008.
Whenever I’m faced with a project in which I have to create a lot of tedious and repeating code I turn to the power of XML and XSLT. Rather than copy/paste the same code over and over again, just to end up with a refactoring and maintenance nightmare, I create an XML definition file and an XSLT transformation. I am then free to add new elements to the XML definition or to change the way the final code is generated from the XSLT transformation. This can be fully integrated with Visual Studio so that the code generation happens at project build time and the environment shows the generated code as a dependency of the XML definition file.
A few examples of how I’m using this code generation via XSLT are:
- Data Access Layer
- I know this will raise quite a few eyebrows, but I always write my own data access layer from scratch and is generated via XSLT.
- Performance Counters
- I create all my performance counters objects via XSLT generation, automating the process of defining/installing them and the access to emit and consume the counter values.
- Wire Frames
- In any project that has networking communication I access the wire format from classes generated via XSLT that take care of serialization and validation.
For example I’ll show how to create a class library that can be added to your project to expose Performance Counters from your application.
Read the rest of this entry »