Sunday, 10 June 2007

A couple of tips for Gadget Development

One tip which is very useful for your Gadget development is to wire up script debugging so you can debug into your Gadget JS from Visual Studio and work out whats going on.

To enable script debugging you need to set the options in Internet Explorer - untick the following two boxes and close off all instances of IE and the Sidebar, and then fire up the Sidebar.


To work with breakpoints you can just set a breakpoint in your JS file and then attach the debugger to the instance of sidebar.exe which is hosting your Gadget. The Sidebar will start up a number of instances of sidebar.exe, so initially you will have nothing to attach to.

A tip here is that you can inject a statement "debugger;" into your Javascript (at an appropriate point) to force it to raise a Script Breakpoint exception that will allow you to attach a debugger at that point to get things going. Very useful for catching the Gadget earlier in the load cycle.

Once your debugger is attached your breakpoints and watches will all operate as expected.

A couple of tips for Gadget Development

No comments: