<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.wintellect.com/CS/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Andy Hopper's Blog</title><link>http://www.wintellect.com/CS/blogs/ahopper/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>Windows 2008 + MacBook Pro == Happy Andy</title><link>http://www.wintellect.com/CS/blogs/ahopper/archive/2008/06/02/windows-2008-macbook-pro-happy-andy.aspx</link><pubDate>Tue, 03 Jun 2008 00:07:00 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:6660</guid><dc:creator>ahopper</dc:creator><slash:comments>4</slash:comments><comments>http://www.wintellect.com/CS/blogs/ahopper/comments/6660.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/ahopper/commentrss.aspx?PostID=6660</wfw:commentRss><description>&lt;TABLE class=""&gt;

&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;I have now been running Windows 2008 on a MacBook Pro for over a month, and I have to report that it's the only way to fly. This thing is ever so shiny, light, and FAST. I'm running the x64 flavor of 2008, and it truly is Vista the way Vista should have been.&lt;/P&gt;
&lt;P&gt;However, being a dev, I can't just leave it at that; I must complain about &lt;EM&gt;&lt;U&gt;something!&lt;/U&gt;&lt;/EM&gt; While Boot Camp has done a great job at providing drivers for the hardware, there are some notable hiccups; the Bluetooth drivers appear to be out of date (I've checked; the hardware IDs for my MBP's hardware&amp;nbsp;look to be from a newer version of the hardware than the drivers know to look for), tap to click is AWOL, and S3 sleep sometimes decides to fail (the machine refuses to sleep and the screen blacks out - and will remain so until a hard reboot). All that being said, I still highly recommend it.&lt;BR&gt;&lt;BR&gt;Now, if I can just find a way to replace that glowing Apple logo on the back of the LCD with a Windows logo...&lt;/P&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;IMG title="Hi, I'm a MaaAAAAAIIIEEEE!!!" style="BORDER-RIGHT:gray thin solid;BORDER-TOP:gray thin solid;BORDER-LEFT:gray thin solid;BORDER-BOTTOM:gray thin solid;HEIGHT:260px;" height=260 alt="Hi, I'm a MaaAAAAAIIIEEEE!!!" hspace=0 src="http://www.wintellect.com/cs/photos/ahopper/images/6659/original.aspx" width=259 border=0&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=6660" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/ahopper/archive/tags/Apple/default.aspx">Apple</category><category domain="http://www.wintellect.com/CS/blogs/ahopper/archive/tags/Windows+2008/default.aspx">Windows 2008</category></item><item><title>Fantastic news from the development tools front!</title><link>http://www.wintellect.com/CS/blogs/ahopper/archive/2008/05/29/fantastic-news-from-the-development-tools-front.aspx</link><pubDate>Thu, 29 May 2008 11:52:00 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:6636</guid><dc:creator>ahopper</dc:creator><slash:comments>0</slash:comments><comments>http://www.wintellect.com/CS/blogs/ahopper/comments/6636.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/ahopper/commentrss.aspx?PostID=6636</wfw:commentRss><description>&lt;P&gt;When I left Microsoft, I felt pretty sad. Not only would I leave a bunch of great friends behind (and REALLY good benefits) - I was leaving my beloved Toolbox behind! (Toolbox is an internal site that has TONS of tools and apps written by Microsoft employees) So, imagine my intense happiness when some of my favorite tools finally surfaced for public consumption!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/sourceanalysis/archive/2008/05/23/announcing-the-release-of-microsoft-source-analysis.aspx"&gt;Microsoft Source Analysis for C#&lt;/A&gt; - This was called StyleCop inside the walls of Microsoft. What is it? It's a source-code analysis tool that you can use to ensure that everybody in your org is adhering to your coding guidelines. It can be a bit (ok, VERY) pedantic sometimes, but you can dial down the level of nitpick.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://robmensching.com/blog/archive/2008/05/16/Deployment-Tools-Foundation-joins-the-WiX-toolset.aspx"&gt;Deployment Tools Foundation&lt;/A&gt; - At MSFT, whenever I needed to do something in managed code during setup, I'd reach for this great internal tool for creating managed custom actions. It worked fairly well, even if it did hit many of the issues Rob Mensching had enumerated for why &lt;A href="http://robmensching.com/blog/archive/2007/04/19/Managed-Code-CustomActions-no-support-on-the-way-and-heres.aspx"&gt;WiX had no roadmap for managed custom actions&lt;/A&gt; a year or so ago. Well, Jason's a smart fellow, and he addressed those issues in the latest version, which has become DTF.&lt;/P&gt;
&lt;P&gt;Lastly, Bob Arnson has released &lt;A class="" title="New WiX feature: Firewall extension" href="http://www.joyofsetup.com/2008/05/17/new-wix-feature-firewall-extension/"&gt;a great WiX extension for creating exceptions&lt;/A&gt; in Windows Firewall by adding a couple of new elements to your WiX code.&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=6636" width="1" height="1"&gt;</description></item><item><title>Instrumentation, Your App, and You - Part II: Eventing</title><link>http://www.wintellect.com/CS/blogs/ahopper/archive/2008/04/28/instrumentation-your-app-and-you-part-ii-eventing.aspx</link><pubDate>Tue, 29 Apr 2008 00:19:00 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:6091</guid><dc:creator>ahopper</dc:creator><slash:comments>1</slash:comments><comments>http://www.wintellect.com/CS/blogs/ahopper/comments/6091.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/ahopper/commentrss.aspx?PostID=6091</wfw:commentRss><description>&lt;P&gt;This is a continuation of my inaugural blog series on instrumentation (see part one &lt;A class="" title="Part One" href="http://www.wintellect.com/cs/blogs/ahopper/archive/2008/04/28/instrumentation.aspx"&gt;here&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;Eventing is one of those features&amp;nbsp;in the .NET Framework that is incredibly useful, especially if you are an Enterprise or Internet-facing application&amp;nbsp;developer. Proper eventing instrumentation can make the difference between an operable application and something your IT guys would&amp;nbsp;never allow in the datacenter. Unfortunately, it is also really easy to abuse.&lt;/P&gt;
&lt;P&gt;OK, this is where I&amp;nbsp;don my Pedantic Instrumentation Guy hat. Yes, I'm going to be an annoying PIG that asks you to do a bit of work in order to have good instrumentation so you don't have to pay some ex-green-beret a lot of money to wade through mini-dumps. (Not that we mind the income, mind you!)&lt;/P&gt;
&lt;P&gt;All too often, developers will use the event log as a poor man's trace log - they'll dump informational messages into the Application log or, worse yet, perform full stack dumps into the log when an exception is caught. In addition, it's just too easy to configure programmatically, which can set you up for embarrasing crashes.&lt;/P&gt;
&lt;P&gt;You see, the event log was not intended to act as a log file; instead, it is intended to be a place where you can go to see a comprehensive view of important things happening on your system. There are two magic words in there I want to emphasize: comprehensive and&amp;nbsp;important. You must understand that you are not the only application writing to the event&amp;nbsp;log. In fact, there's a phenomenon known as an "event storm" where a poorly written application can flood a computer's event log with so much useless or redundant data that other things that are really useful to see like warnings from SQL or disk I/O errors get missed. This logically brings us to event importance. You really should only be logging significant events. Things like startup, shutdown, catastrophic failures but most importantly, &lt;U&gt;recoverable&lt;/U&gt; errors.&lt;/P&gt;
&lt;P&gt;Ahhh, recoverable errors. PIG hat still on? Ah, good. This topic could (and probably will) merit a whole series of posts&amp;nbsp;dedicated to knowing/learning&amp;nbsp;how your applications&amp;nbsp;may fail.&amp;nbsp;Here's a Golden Rule of eventing: Do not log an error if all your poor sysadmin can do is see that the application has logged an error. Trust me; he's not going to appreciate the event message for its innate beauty. If there is no possible recovery action documented for a particular error event ID (or even better, included in the event's message), then all your app is doing is indicating to the sysadmin that he should seriously consider uninstalling your application. Consider this: you see the following error event:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Log Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Application&lt;BR&gt;Source:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyApplication&lt;BR&gt;Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5/8/2008 7:00:00 AM&lt;BR&gt;Event ID:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;BR&gt;Task Category: (0)&lt;BR&gt;Level:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Error&lt;BR&gt;Keywords:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;User:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N/A&lt;BR&gt;Computer:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datacenter1&lt;BR&gt;Description:&lt;BR&gt;Object not set to an instance of an object.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did this tell you anything about how you can prevent this error in the future? If not, why is it in the event log? If it doesn't provide me with a way to help my system be happy again, it's just noise. The best I can do is to attach a debugger and snap a minidump when I hit a NullReferenceException, and this is not something to consider lightly when you've got an Internet-facing application (Or tight purse-strings. Do you know how much it costs to hire ex-green-berets these days?).&lt;/P&gt;
&lt;P&gt;No, a much better error event would be:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Log Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Application&lt;BR&gt;Source:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyApplication&lt;BR&gt;Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5/8/2008 7:00:00 AM&lt;BR&gt;Event ID:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1033&lt;BR&gt;Task Category: (3)&lt;BR&gt;Level:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Error&lt;BR&gt;Keywords:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;User:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N/A&lt;BR&gt;Computer:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datacenter1&lt;BR&gt;Description:&lt;BR&gt;Unable to retrieve customer information from the database. Please verify that the 'customer' database at server 'database2' is accessible.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, what's the difference here? Well, there's the obvious difference and the hidden one. The obvious difference is that the event gives you a pretty good indication of what's going on. In addition, it gave you some things to go check to help your app get back on its feet: is the database server up and running? If so, is the database available? The hidden difference is that the developer anticipated that he may not get a valid object from the call to retrieve an object from the server and wrote error-handling code to capture the information needed to troubleshoot the problem and to write the above entry. I'm not going to lie and say that it's easy to write code that anticipates failure. It's actually pretty hard to know all of the ways in which some component can fail, especially if you didn't write it yourself. Some of this will come from experience and testing, and there are also static analysis tools that can analyze your code's call stacks for exceptions that aren't handled but if you're really lucky, the developers who wrote the component will have included things like &amp;lt;exception&amp;gt; information in their XML documentation. With all of the above and some grunt-work on the developers' part, you should be able to tell your sysadmin what is wrong with your app. So what if you encounter a truly exceptional exception? Well, that falls under the category of catastrophic failure. For obvious reasons, it's your responsibility to try to minimize the scenarios where one of these can occur, but if it were to happen this is where all of the helpful advice I provided in the tracing article (you DID read that, right?) comes in.&lt;/P&gt;
&lt;P&gt;Oh, one other thing you may notice in my "new and improved" log message is that there was an event ID. This is also a pretty important concept: once you've spent the time to analyze the manner in which your application can fail, try to assign event IDs to the cause of failures you are logging. For example:&amp;nbsp;an inability to connect to the database server is 1033,&amp;nbsp;an access denied to a configuration file may be 2021, and so on.&amp;nbsp;If you do your homework here you can not only make it easier for a human being to find and correct the issue preventing your application from functioning but you can facilitate the development of auto-recovery actions in monitoring packages like &lt;A class="" title="System Center Operations Manager" href="http://www.microsoft.com/systemcenter/opsmgr/default.mspx"&gt;System Center Operations Manager&lt;/A&gt;. Spending the time to itemize your event messages also allows you to leverage the string formatting and localization capabilities of the Message Compiler (mc.exe) utility. I'll dedicate a separate post to how one can use MC.exe to generate message files and how you can register and use event sources that use message files.&lt;/P&gt;
&lt;P&gt;Finally, let's talk about event source registration. Again, this is one of those areas where things were made a wee bit too easy. A pattern you see too often in managed code is:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;if (!EventLog.SourceExists("Foo"))&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EventLog.CreateEventSource("Foo", "Application");&lt;BR&gt;}&lt;BR&gt;EventLog.WriteEntry("Foo", "Some event", EventLogEntryType.Information);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In fact, I was apalled to discover this code in a Microsoft certification exam! You should never ship code like the above for a couple of reasons, but the most obvious one is that it requires elevated permissions to create an event source. If an unprivileged user account attempts to run the above you will get a SecurityException. Instead, have your installation package leverage Windows Installer's support for registering event message files and use the WriteEvent overload instead - that way, you can create an EventInstance object that contains the event message ID and supply format strings that get plugged into the appropriate place in the message.&lt;/P&gt;
&lt;P&gt;Well, there you have it. A whirlwind tour of the philosophy behind proper* event logging in your application.&lt;/P&gt;
&lt;P&gt;Whew. Now I can take this stupid thing off.&lt;/P&gt;
&lt;P&gt;* "Proper" is in the eye of the beholder. Feel free to ignore any and all of my advice. Tax, tag and title not included in the advertised sale price.&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=6091" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/ahopper/archive/tags/Instrumentation/default.aspx">Instrumentation</category><category domain="http://www.wintellect.com/CS/blogs/ahopper/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Instrumentation, Your App, and You - Part I: Tracing</title><link>http://www.wintellect.com/CS/blogs/ahopper/archive/2008/04/28/instrumentation.aspx</link><pubDate>Mon, 28 Apr 2008 23:38:00 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:6090</guid><dc:creator>ahopper</dc:creator><slash:comments>1</slash:comments><comments>http://www.wintellect.com/CS/blogs/ahopper/comments/6090.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/ahopper/commentrss.aspx?PostID=6090</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;It's been a while since I've blogged about anything technical, and since I'm here in my new home at&amp;nbsp;&lt;A class="" title=Wintellect href="http://www.wintellect.com/" target=_blank&gt;Wintellect&lt;/A&gt;&amp;nbsp;I decided that I need to begin anew. So, without further ado...&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;I wish I could find a way to make instrumentation sexy; every time I try to explain to someone about why they should invest in instrumentation, I see them get the “deer in the headlights” look and try to find a way to get away from this crazy bald man. It’s just so BORING… and invaluable.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;Basically, my philosophy is that attaching a debugger is well and good, but there are only a few scenarios where that’s going to be possible or acceptable. With Enterprise-facing Web or LOB applications, you have a lot of leeway – they can afford to have you (or one of their technical resources) go to a machine and attach &lt;A class="" href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx" target=_blank&gt;WinDBG or CDB&lt;/A&gt; – but I hold Internet-facing sites and client-side code to a much higher bar. With a live Internet-facing site, you can’t just hit a breakpoint and dig around as it brings the app to a screeching halt. Even scripting a breakpoint that snaps a minidump and resumes is no good as it still blocks the app for an indeterminate (although admittedly pretty short) amount of time. With a client-side application, you simply cannot ask a customer to install a debugger and get that minidump to you.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;So, how can you instrument your application? Well, there are three primary ways and one interesting way. You can use trace logging (which will be the core focus of this post), event logging, performance counters, and finally, WMI.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;There are plenty of times where that hard-won minidump simply isn’t enough; after all, not only is it rocket science to most developers, but all you’ll see stack traces and current values for members – not HOW you got to this point. A lot of the art debugging is intuiting what path the app took to get to this crashing stack, and a good trace log can let the app do a lot of that detective work for you. Even minimal stack tracing (entry/exit) gives you a great deal of behavioral information, and this can be invaluable when you’re trying to figure out WHY you’re waiting on that Mutex again. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;Tracing undeniably has a non-zero overhead associated with it, and this overhead takes two forms. First, there’s the behavioral/code overhead that goes with getting people in the mindset of leaving post-it notes in their code for the unfortunate soul who has to troubleshoot their misbehaving app. Second, there’s the performance overhead that goes along with adding more calls to the application. The first is manageable, and the second is fixable.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;On the behavioral front, it’s very much an evangelism issue and it’s kinda like selling insurance for your career. Once you have an app out in the field with zero instrumentation and some high-profile customer is screaming for your head because you STILL don’t know why your app is hitting this exception, you gain a deep appreciation for how much you would have loved to know what the response from that SOAP call was. As for the amount of work it requires from the developer, it all depends upon the class of application; there’s a dial you’ll want to turn for the amount of tracing code you write. When I’m wearing my hard hat I want tracing at every decision block, every exception handler to dump the exception and logging the parameters to methods at “verbose” levels. When I’m wearing my “warm fuzzy” hat for simple LOB applications, I want tracing before and after major events in the code like network/IO calls. But in practice, it’s going to be up to the dev to understand how their code might misbehave and to leave a trail of tracing breadcrumbs to help some poor soul noodle out why some button didn’t get enabled.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;FONT face=Calibri size=3&gt;Now on to the performance overhead. Most developers don’t stop to think about the cost associated with constructing the call stack for a trace call, and when they see that their application’s runtime performance suffers because they have a bazillion trace calls that call ToString or box up a bunch of integers, they’re quick to blame tracing in general and yank it altogether (seen it happen first-hand, that). There’s no reason it has to be this expensive, though. If tracing isn’t enabled, it should just get out of the way – it’s only when we’re debugging that we want that overhead, and then we won’t care as much if we take a hit. It’s an unfortunate reality that all of the wonderful work the driver guys did on &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms793176.aspx" target=_blank&gt;TraceWPP&lt;/A&gt; is lost in the managed world; there’s no (publicly available, that is) tool for preprocessing managed code and wrapping trace calls with runtime-evaluated conditionals to shortcut the construction of the call stack if tracing is not enabled.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;So, if we can't use TraceWPP, what can we do, then? Well, for the time being (hint, hint), we're stuck with hand-generating conditional blocks to detect whether tracing is enabled for a particular trace level. However, I hope to remedy that situation here in this blog: we'll walk through the implementation of a preprocessor in the style of TraceWPP and use it for our managed apps.&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;Well, this post has become long enough for now. We'll take a look at the other ways your application can help you debug itself later.&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=6090" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/ahopper/archive/tags/Instrumentation/default.aspx">Instrumentation</category><category domain="http://www.wintellect.com/CS/blogs/ahopper/archive/tags/.NET/default.aspx">.NET</category></item></channel></rss>