Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

SCOM event collection fails with (0x8007000E)

I have written some custom SCOM management packs that read from a database and populate event collection data (see here and here for some examples from other people). My first management pack works without any problems. The second management pack (essentially a copy of the first) fails with an out of memory exception. The Operations Manager event log on the SCOM server contains an entry that starts with the following:

Converting data batch to XML failed with error “Not enough storage is available to complete this operation.” (0x8007000E) in rule “[RuleName]”

This has been plaguing me for weeks but I now have an answer.

The definition of a collection event record includes a description field. The description field may be defined with a static value, a property bag (params) value or combination of both. The property bag value can be fully qualified (in the format of $Data/Property[@Name=’<PropertyBagItemName>’]$) or referenced by index. See here for more information.

Read More

Visual Studio Addin - CopySourceAsHtml

Ah, this is great news. A new version of CopySourceAsHtml (CSAH) has just be released with support for VS2008 after a long hiatus. CSAH is a must Visual Studio addin for any developer blogger. Get the goods here.

Read More

Testing IErrorHandler

I have previously posted (here, here and here) about using IErrorHandler to provide error handling and exception shielding in WCF services. What I haven’t discussed is how to test an implementation of this interface.

The reason for posting this is that I recently found that I had a bug in a service where un-handled exceptions weren’t being shielded from clients. This was purely because my unit tests were not validating the messages being generated for clients by the error handler.

The following method came about after a bit of research (mainly from here) and playing with code to make the solution work and easy to use. This method will assist unit testing the output of ProvideFault as it provides an easy way to extract a Fault from a Message returned by the ProvideFault method. This fault can then be tested for expected outcomes of the unit test.

Read More

Splitting up arguments with a regular expression

There have been several times when I have needed to process a string that contains a set of arguments. It always seems to be a lot of work splitting up arguments by using white space as a delimiter because you need to take into account white space that is surrounded by brackets.

Just for kicks, I tried to come up with a regular expression that would do just that. Here is the result.

[^\s"]*"[^"]*"[^\s"]*|[^\s"]+
Read More

SQLEXPRESS fails to start

I have just encountered a problem where the SQLEXPRESS instance installed on my machine was not starting. It looks like a recent windows update has failed, but also knocked out SQL Server. The event log contains the following entry:

Error 3(error not found) occurred while opening file ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf’ to obtain configuration information at startup. An invalid startup option might have caused the error. Verify your startup options, and correct or remove them if necessary.

After searching around, there seems to be lots of forum posts going back several years about this issue. The problem is that the only known solution seems to be to change the credentials of the SQLEXPRESS service account to Local System. This will then allow the service to start. Doing this through the services console presents a problem however because you can’t set the service credentials back to Network Service as you need to know the password.

Read More

Troubleshooting DataDude deployment with TeamBuild

I’m working through the best way of getting DataDude to build and deploy a database using TeamBuild. When I kicked off a build, the build script failed with the following error:

Task "SqlBuildTask"   
  Building deployment script for [DatabaseName] : AlwaysCreateNewDatabase, EnableFullTextSearch, BlockIncrementalDeploymentIfDataLoss   
MSBUILD : Build error TSD158: Cannot open user default database. Login failed.   
MSBUILD : Build error TSD158: Login failed for user '[TeamBuildUserName]'.   
Done executing task "SqlBuildTask" -- FAILED.
Read More

Guidance on use of include in XML documentation comments

I have previously posted about using the include element for my XML documentation in cases where there is duplicated content. After a recent code review, the reviewer commented that the include element made it difficult to read the documentation because large parts of the XML documentation were abstracted out to an XML file. This made me look at ways around this and the affect of the include tag had on the tooling support.

As a quick overview, the include element in XML documentation tells the compiler to go to the specified XML file and run an XPath query (recursively). It pulls in the result of that XPath query and injects the content into the XML documentation being generated for a code element.

Read More

Tracing Performance Tips

I have recently been working with tracing performance and have posted several tidbits of information. Here is the overview.

  1. Use TraceSource instead of Trace
  2. Disable global locking
  3. Clear the default listener in configuration
  4. Don’t collect stacktrace information if not required
  5. Create TraceSource instances once per name and cache for reuse. I have encountered memory leaks from creating large numbers of instances of the same TraceSource name.
  6. Create a unique TraceSource and TraceListener for each logical part/tier/layer of the application (locking performance and data segregation)
  7. Use thread safe listeners if possible
  8. Check TraceSource.Switch.ShouldTrace before calculating any expensive information to provide to the trace message

On a side note, don’t forget to turn off code coverage for running load tests.

Read More