How to cope with designer errors in Visual Studio

From time to time, when you have some errors in your controls, Visual may just stop responding altogether and forces you to restart without any indicator on what happened and how to fix it. To overcome this, there is two things developers should keep in mind:

  1. Check database and connection routines, make sure they are initialized properly or blocked from running by checking the special property DesignMode (available as Form.DesignMode and UserControl.DesignMode).
  2. To see the cause of the error, you have to debug Visual Studio itself. When designer error happened to you, choose debug this program and start a new instance of Visual Studio. The second instance should give you the unhandled exception and the code location of the error.
I think this is an artifact from the first days of Visual Studio carried over when they expect all code to behave (after all, developers have to spend years just for planning and resources is not available as much as today). For this Microsoft are way behind Eclipse: In android development tools, if you have errors in your control, the designer at least give you a message about the error and refuses to continue rendering the screen but it won’t crash. Visual Studio, on the other hand, requires a full restart which consumes a lot of time (this particular time it took me 2 hours to find the source of the error).

Debugging the Galaxy Tab 10.1

When I first plug the tab in, my computer automatically install all the drivers, but it won’t show up in ADB and Eclipse. I did a little searching but people were pointing me to Samsung’s developer page with a USB driver for phones. Sadly that driver just isn’t for the tab, a search on their site found nothing interesting either. It looks like Samsung can’t keep information for developers updated while they are still battling legal issues around the tab.

Fortunately, I remembered I haven’t turned debugging mode on the tab on, so I went ahead and do it, this time… Success!

Where to turn on debugging

Device in Eclipse

Now I’m installing Android 3.1 platform and looking forward for a happy time debugging 🙂

Debug on Android device

I once thought I just have to plug the device in, install all the driver and when it appeared in ADT’s device window I can just start debugging; but sadly this is not the case. Here’s a very informative guide on how to do so by Google.

Because I was too lazy to read that, I can start the program but it will not hit any breakpoint I set. I missed the first point in the guide above: I have to set debug=”true” in the application’s manifest!

<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">