Wintellect  

I have long held a grudge against Google. Not because they were evil or anything; just that I worked for Microsoft, and Google was the enemy: they wanted to steal the food from our children's mouths, kicked puppies and whatnot. However, I have finally come to grips with this resentment, and GOOG's is now all right with me.

So, what made this happen? A few things, all with one single point of concentration: my Nexus One. Not only is is an AWESOME phone, but the SDK runs on every major OS (via Eclipse) and their policy for listing applications in their marketplace is very egalitarian. I'll need to dust off my Java skils for the time being, but one of my favorite open-source projects (Mono) is working on a port to Android, so I'll be able to re-use my C# code (to some degree)!

If you're on T-Mobile or AT&T, I highly recommend it.

I'll be presenting on Windows Identity Foundation today on GeekSpeak (http://blogs.msdn.com/geekspeak/)! Please tune in and ask questions, but if you miss it, they'll be recording it for posterity.

Download the bits here

And the SDK is here

At long last, there are Azure tools for Visual Studio 2010 Beta 2! You can get the bits here.

 

This is the slide deck I presented at Microsoft's BizSpark Incubation Week. For your convenience, here are the links from the reference slide:

Download the deck here

Windows Azure Developer’s Portal
http://www.microsoft.com/azure/windowsazurefordevelopers

Known Issues With WCF and Azure
http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues

Codename “Geneva”
http://www.microsoft.com/geneva

Windows Azure and Passive Federation (provides Microsoft.IdentityModelPlus)http://code.msdn.microsoft.com/wifwazpassive

We have just published the source for my port of Sergio's Silverlight 3 game Cascade to the Silverlight for Windows Embedded platform! Now if I can just find a handheld device that's shipping with SilverlightCE on it...

Check out CascadeCE

I am now delighted with Windows on a MacBook Pro. With the exception of some Apple-specific hardware, namely the multi-touch features of the trackpad and the iSight camera, the Win7 RTM disk had decent drivers for everything. With the new taskbar and Aero Peek & Snap features, I don't even feel UI envy when I switch to OSX!

Way to go, Microsoft!

For those of you who may not have seen the news, trhe Live Framework will be shut down on September 8th. Please ensure that any content you have uploaded to your Cloudboards has been archived.

However, all is not lost; we are feverishly working on a replacement for the Live Framework backend. It may not be as seamless to set up as it was with Live Framework, but rest assured that we'll come up with a way for things to resume working shortly!

I have been working with Jeffrey Richter to create a shared clipboard tool named Cloudboard. Jeffrey will be presenting this tool as part of his Live Framework talk at Devscovery Redmond next week, but in the meantime the tool itself is ready for use (and hopefully not too many bug reports). You may get the bits (and source) at http://cloudboard.codeplex.com.
NTrace, my open-source ETW tracing framework, has just released a minor revision increment. In this revision, I fixed a couple of MSBuild issues that prevented WPF apps from using NTrace. You can get the latest bits at http://ntrace.codeplex.com.

Chances are that you haven't heard about VirtualBox. It is yet another virtualization environment, but it has some great features. It has support for Linux/OSX/Windows as the host OS and Linux/BSD/Windows/etc as guest OSes (both x86 and x64), it supports 3D (via OpenGL) acceleration, and it's free to boot! I highly recommend it. (It even plays nice with Windows 7!)

http://www.virtualbox.org

I’m pleased to announce the general availability of the NTrace library and preprocessor. NTrace is a combination of a runtime library and a preprocessor that enables you to incorporate the same kind of tracing flexibility and performance that was previously only available to the lucky folks still writing unmanaged code. There are a log of advantages to using NTrace/ETW: higher performance, flexibility, and zero-config tracing.

In terms of performance, we’re talking orders of magnitude faster when no tracing is being performed, and 2-3 faster when tracing is enabled. This is critical in applications that require the highest performance under heavy load (Internet-facing apps, Enterprise applications, etc.). For obvious reasons, you’ll take a hit once you enable tracing, but the ETW subsystem mitigates this to a large degree.

 

In terms of flexibility, you can configure ETW tracing to log in many different ways: real-time to a console (similar to listening to the OutputDebugString spew), logging to a flat binary file, logging to a binary circular log, and for those with intestinal fortitude, writing a custom ETW listener (we do plan to eventually surface this via the NTrace API as well).

 

However, I’ve saved the best for last: one of the best features of the ETW tracing APIs is the ability to turn tracing on in your applications without needing to modify any configuration files or restart it (this is especially important for Internet-facing WCF and ASP.NET applications!).

 

I hope you’ll take the time to download the latest bits, kick the tires, and provide feedback. And of course, this is an open source project (licensed under the Eclipse Public License), so contributors are welcome!

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.

However, being a dev, I can't just leave it at that; I must complain about something! 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 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.

Now, if I can just find a way to replace that glowing Apple logo on the back of the LCD with a Windows logo...

Hi, I'm a MaaAAAAAIIIEEEE!!!

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!

Microsoft Source Analysis for C# - 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.

Deployment Tools Foundation - 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 WiX had no roadmap for managed custom actions a year or so ago. Well, Jason's a smart fellow, and he addressed those issues in the latest version, which has become DTF.

Lastly, Bob Arnson has released a great WiX extension for creating exceptions in Windows Firewall by adding a couple of new elements to your WiX code.

This is a continuation of my inaugural blog series on instrumentation (see part one here).

Eventing is one of those features in the .NET Framework that is incredibly useful, especially if you are an Enterprise or Internet-facing application developer. Proper eventing instrumentation can make the difference between an operable application and something your IT guys would never allow in the datacenter. Unfortunately, it is also really easy to abuse.

OK, this is where I 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!)

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.

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 important. You must understand that you are not the only application writing to the event 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, recoverable errors.

Ahhh, recoverable errors. PIG hat still on? Ah, good. This topic could (and probably will) merit a whole series of posts dedicated to knowing/learning how your applications may fail. 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:

Log Name:      Application
Source:        MyApplication
Date:          5/8/2008 7:00:00 AM
Event ID:      0
Task Category: (0)
Level:         Error
Keywords:     
User:          N/A
Computer:      datacenter1
Description:
Object not set to an instance of an object.

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?).

No, a much better error event would be:

Log Name:      Application
Source:        MyApplication
Date:          5/8/2008 7:00:00 AM
Event ID:      1033
Task Category: (3)
Level:         Error
Keywords:     
User:          N/A
Computer:      datacenter1
Description:
Unable to retrieve customer information from the database. Please verify that the 'customer' database at server 'database2' is accessible.

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 <exception> 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.

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: an inability to connect to the database server is 1033, an access denied to a configuration file may be 2021, and so on. 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 System Center Operations Manager. 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.

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:

if (!EventLog.SourceExists("Foo"))
{
    EventLog.CreateEventSource("Foo", "Application");
}
EventLog.WriteEntry("Foo", "Some event", EventLogEntryType.Information);

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.

Well, there you have it. A whirlwind tour of the philosophy behind proper* event logging in your application.

Whew. Now I can take this stupid thing off.

* "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.