It’s always good to be a able to attach a debugger to a program to see how it does its work – animating code makes it far easier to understand that just reading through static source. While trying to get a better understanding of WinRT, I came across the following tool which lets you attach a debugger to a system launched WinRT package from just after it has started up.
If we take a simple WinRT Silverlight application.
As we know, this type of application is compiled into a package. A package is identified using a guid.
It is registered into the registry of the machine.
Using the details about the package, the WinRT tool lets you associate a debugger with it. I downloaded cdb onto my virtual machine, and set that up as the associated debugger.
Launching the application in the Metro interface leads to an instance of cdb.
We can set some breakpoints to see when the Windows Runtime is being initialised.
We see this is happening as the CLR is starting up
We can look at the start up environment of the dll that was generated for the application.
The real start up happens when an instance of the activation factory is created.
Now we have a tool for getting into the code before it runs, we have the ability to do more investigation of what is going on. I hope to blog more about that in the future.