blogger counters

Tuesday, August 29, 2006

Viewing Compact Framework Source

Many of us who develop for the Pocket PC have discovered that we can't use tools like Reflector to view to source code for the assemblies Microsoft provides, such as System.Windows.Forms. To see what I mean, try this. Open Reflector and from the File menu, select Open List... This will display the Assembly List Management dialog box, which allows you to create lists of assemblies so you can quickly load the assemblies you want into Reflector.

Next click on the Add button to create a new assembly list. I called my list "Compact Framework 2.0". Click on the Select button and you'll get a list of assemblies you can use to initially populate your new list. I selected .NET Compact Framework 2.0 from the Start 'Compact Framework 2.0' Assembly List dialog box and then clicked on the OK button to add these assemblies to the list.

Now if you open the a class, like ButtonBase in System.Windows.Forms, and display the source, you'll see something like this:

This certainly isn't very useful. Well, my colleague Daniel Cazzulino posted a question about this and got an answer. Now that I think about it, it makes perfect sense that you can't get source from the shipping assemblies. In order to keep the installed size as small as possible, the Compact Framework team removed the reflection information.

However, if you have Visual Studio, it ships with a separate set of assemblies that include all the reflection information. I created a new list in Reflector, but this time I clicked on the Cancel button when it asked me what assemblies I wanted in my list. Then I selected Open from the File and and added the assemblies that were installed here on my computer:

C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\CompactFramework\2.0\v2.0\Debugger\BCL

Now I get the source code, as shown here, for the same exact class:

Very nice! Thanks Daniel!

0 Comments:

Post a Comment

<< Home