| Jonathan 的个人资料Jon's Vista Gadgets Blog日志列表 | 帮助 |
|
|
4月24日 HOW TO: Debugging GadgetsDebugging Gadgets can be a little frustrating, not only whilst coding; but also when trying to get useful feedback from users who've reported issues. The simplest way to achieve this, is to log debug entries out to a file. In the example below, we check to see if "debug.txt" exists in the Gadget folder and if it does write debugging information to it. The first step is to see if the file exists and open it. In the following code, we create a BOOLEAN variable "bDebug" which we can use later to output more detailed information, beyond simply errors:
It's good practice to get into the habit of wrapping all your functions in a try/catch loop, to prevent Runtime errors from popping up:
It's also a good idea to put in tracking information, so you know where you are in the code. For example:
To enable "debug mode", simply create a blank text file in your Gadget folder called "debug.txt". Personally, I put this code into all Gadgets and leave "debug.txt" out of the Gadget package. When a user reports an issue, I ask them to create the file and eMail it back to me once they've reproduced the problem.
Whilst your developing your code, I'd also advise running Microsoft's Debug View; which will allow you to watch all debug entries as they occur. In a future article, I'll detail how to write out debugging information from VB and C++ ActiveX DLL's. 评论 (1)引用通告此日志的引用通告 URL 是: http://vistagadgets.spaces.live.com/blog/cns!D8F26C345B42BC67!222.trak 引用此项的网络日志
|
|
|