Today I had my first experience with using manifest files for Win32 binaries. If you're only familiar with .NET manifest, never fear, as Windows itself uses essentially the same mechanisms.

In my particular case, I wanted to ensure that a DLL I wrote always linked to the latest and greatest DBGHELP.DLL in the same directory as the DLL. Without going into to much detail, suggestions like "just use a .local file", and "Just use LoadLibrary/GetProcAddress" weren't cutting it for me.

I'll save a detailed description of how I got to work till later. The important thing here was that I struggled for awhile to get the exact manifest XML syntax just right. When it wasn't correct, the loader would refuse to load the DLL, but wouldn't offer much more guidance on what was wrong.

Later in the day, I happened to be looking in the Event Viewer, and wandered through the "System" log just for fun. Lo and behold, I saw a bunch of red "Error" events sourced by "SideBySide". Opening these events up, I found a much more detailed description of what the loader didn't like. A typical entry:

"Syntax error in manifest or policy file "C:\projects\xxxx\Debug\Microsoft.XxxXxx.MANIFEST" on line 4."

So, next time you find yourself struggling with Win32 manifest, take a peek at the System events in the Event Viewer.