Professionally speaking, I left COM behind years ago, when I decided to focus on .NET full-time. I've been lucky enough to have that career option. Of course, it doesn't mean that I've forgotten what I know about COM, and sometimes that knowledge comes in handy. Other times, I'm reminded of how confusing that stuff has always been, and I'm even more grateful I could move on.
Take tonight. I was coding along, working on my implementation of FlexWikiPad. I wanted to pop up a dialog box so the user could choose a folder to store the wiki in. “No problem,” I thought, “I'll just use the built-in folder browser dialog.” Imagine my surprise when I ran the code and got a blank dialog. Oh, it had an OK and a Cancel button, but there was nothing but grey background where the folders on my computer should have been shown.
I did what any good debugger would do, and started stripping down the application, looking for the line of code that was causing the problem. But the application kept getting smaller, and soon it was just an empty form with a button on it. Clicking the button did nothing but open the dialog, and it still had the same problem. I was mystified.
I had a suspicion that something might have gone screwy in the project settings somewhere, so I fired up the project wizard, and I created a second project from scratch, with the intention of using WinMerge to diff the two project files. Only, when I was perusing the generated source code, I saw something that gave me pause. After thinking about it for a second, I went back and made a one-line change in my original program, and sure enough, it started working.
The problem in this case springs from the fact that I tend not to rely on the VS.NET wizards. Rather, I either write my source files from scratch, or I generate them with CodeSmith templates. So I had failed to mark my Main method with that little [STAThread] attribute, which, in the type of .NET programs that I usually write, is actually a good idea. But when you're dealing with controls that interop via COM - as is apparently the case with the folder browsing stuff - it just causes things to go kerbluey in odd ways.