27 March 2012

Creating a Comprehensive Event Logger

Would you rather try to decipher the meaning of an error in the Windows application event log, or ram a fork into the back of your hand?  I thought so.

The problem with the event logs is they are notoriously uninformative.  It seems that their purpose is to taunt IT personnel, by suggesting some helpful information is available. Yeah, right.  There are entire Web sites dedicated to deciphering event identification numbers mean.  The necessity for such sites is just plain sad.  Apparently, leaving what happened a mystery is a better alternative to including actual WORDS that describe the problem, in human language.

I implore you: do not be that kind of developer!  I always insist on making everything human readable, and easy to understand.  By leveraging the extensible nature of .NET, we can easily log useful and meaningful information to the event log, which will help the user or IT administrator fix the problem, and/or help the developer debug the issue.

Here's how you can use a single method, to alleviate the IT admin's urge to strangle you.

28 February 2012

Suppress EF Compiler Warnings Error 11007 and 11008

I am working on an MVVM project that parses records out of encrypted data files, on demand.  There is no real data source for this project, for Entity Framework 4.1 to reference.  Every time I build the model assembly, I get a huge pile of warnings for Error 11007 and 11008.

Because I am a savvy developer (and slightly obsessive-compulsive), I don't want to see any compiler warnings after a build.  Because I know these are non-issue warnings, I can safely disable them.  Here's how to disable EF warnings in your projects:

15 December 2011

Pex and Moles to be Visual Studio 11 Feature Set

In true, "I will neither confirm nor deny" Microsoft fashion, a little bird in Redmond informed me that Pex and Moles will have no further releases, because they are being "productized". Another, larger bird stated, "dependency isolation will be taken care of, in Visual Studio 2012," when I asked if Moles and Pex will be rolled into VS 2012.

The Visual Studio 2012 community technical preview (CTP) is available for download to anybody.  However, the Moles and Pex products are not yet integrated into the application.  There are several points of integration the need to be perfected, before adding it.

Note, this VS11 download is a BETA version, and is incomplete.  Many more features are still cooking.  Stability is OK, but use it at your own risk!  Visual Studio 2012 Beta will (should) receive updates from Microsoft Update, to keep it current with the newest release.


(This post is extracted from the Testing with Microsoft Pex and Moles page of this blog.  I felt this information was worth putting in its own post, after sitting in a sidebar, since May 2011.)

UPDATE: Changed the link and name to reflect the Beta release.

How To Mole the System Assembly

The System namespace may be moled, in addition to any other child namespace.  For instance, you may want to detour calls away from System.StringComparer, which is a member of the System assembly.   To mole members of the .NET Framework "System" namespace, follow these four steps: