Gadgets 侧边栏小工具 跟踪调试方法
2009-07-12 17:41
302 查看
原文地址:http://msdn.microsoft.com/en-us/library/bb456467(VS.85).aspx
This overview describes the various methods and techniques that can be used to debug gadgets.
Debugging a Missing Gadget
Debugging Code
Debuggers
Tips Character Encoding
Fonts
If a gadget appears in the Gadget picker but is displayed with the Sidebar's generic gadget image, ensure that the desired image exists in the gadget file structure and that the path to the image file in the manifest is correct.
Copy Code
This procedure may require repeating if either the gadget drag-and-drop image or the developer's logo is missing or broken.
Copy Code
If the complexity of your gadget code requires a more robust debugging solution then a number of script debuggers are available.
From the menu, click Tools and select Internet Options.
Click the Advanced tab and verify that both Disable script debugging check boxes are not selected.
If using Visual Studio for debugging, click Tools, select Options, and ensure that Just-In-Time debugging is enabled for Script:
To dump specific output to the debugger console, the outputString method can be used:
Copy Code
To break into the gadget runtime at a particular execution point and step through the code, you can place this line of code where necessary:
Copy Code
When the
Once a debugger is selected, the code will be displayed in the debugger with the break point highlighted. From this point you can step through the code and get runtime information for any gadget element:
It is highly recommended that all gadget HTML and script files be saved with UTF-8 character encoding.
The following steps can be taken to ensure the encoding of these files:
Open the file in Notepad.
On the File menu, click Save as...
In the Save as dialog box, confirm that the value in the Encoding drop-down is UTF-8.
If the value in the Encoding drop-down is not UTF-8:
In the Encoding drop-down, select UTF-8.
Click Save to overwrite the existing file.
Repeat this process for all gadget HTML and script files.
注意:
1. 调试的文件地址 C:\Users\用户名\AppData\Local\Microsoft\Windows Sidebar\Gadgets
2. 设置IE后,重启IE,调试。
This overview describes the various methods and techniques that can be used to debug gadgets.
Debugging a Missing Gadget
Debugging Code
Debuggers
Tips Character Encoding
Fonts
Debugging a Missing Gadget
If a gadget fails to appear in the Gadget picker, the likely culprit is an invalid or malformed gadget.xml manifest file. Open the manifest file with Windows Internet Explorer or other XML editor to check.If a gadget appears in the Gadget picker but is displayed with the Sidebar's generic gadget image, ensure that the desired image exists in the gadget file structure and that the path to the image file in the manifest is correct.
Copy Code
<hosts> <host name="sidebar"> <base type="HTML" apiVersion="1.0.0" src="sample.html" /> <permissions>Full</permissions> <platform minPlatformVersion="1.0" /> <defaultImage src="icon.png" /> </host> </hosts>
This procedure may require repeating if either the gadget drag-and-drop image or the developer's logo is missing or broken.
Copy Code
<author name="Microsoft"> <info url="msdn.microsoft.com" /> <logo src="logo.png" /> </author> ... <icons> <icon height="48" width="48" src="icon.png" /> </icons>
Debugging Code
Depending on the complexity of the gadget code, debugging can consist simply of dumping information to the gadget user interface (UI) (similar to simple Web applications) at specific code points or by catching exceptions with atry...catchblock. Microsoft JScript alerts are often used for quick and dirty debugging, but these are not implemented in the Sidebar. If necessary, this limitation can be worked around by using the equivalent Microsoft Visual Basic Scripting Edition (VBScript) MsgBox function.
If the complexity of your gadget code requires a more robust debugging solution then a number of script debuggers are available.
Debuggers
Any script debugger can be used to debug a gadget, including Microsoft Script Debugger, Microsoft Script Editor, and Microsoft Visual Studio. Enabling gadget debugging requires a minor tweak to the Internet Explorer settings:From the menu, click Tools and select Internet Options.
Click the Advanced tab and verify that both Disable script debugging check boxes are not selected.
If using Visual Studio for debugging, click Tools, select Options, and ensure that Just-In-Time debugging is enabled for Script:
To dump specific output to the debugger console, the outputString method can be used:
Copy Code
// -------------------------------------------------------------------- // Attempt to save the file and throw an error if the filename does // not include a file extension. // -------------------------------------------------------------------- function SaveFile() { var fso = new ActiveXObject( "Scripting.FileSystemObject" ); // Throw an arbitrary error to demonstrate the outputString method. try { if (sFilename.indexOf(".") == -1) { throw "'Filename' does not specify a file extension."; } var file = fso.OpenTextFile(sFilePath + sFilename, FOR_WRITING, CREATE_NEW); file.Write(sContent); file.Close(); fso = file = null; } catch(e) { System.Debug.outputString(e); } }
To break into the gadget runtime at a particular execution point and step through the code, you can place this line of code where necessary:
Copy Code
debugger;
When the
debuggerstatement is executed the Visual Studio Just-In-Time Debugger dialog will prompt you to open a registered debugger:
Once a debugger is selected, the code will be displayed in the debugger with the break point highlighted. From this point you can step through the code and get runtime information for any gadget element:
Tips
Character EncodingIt is highly recommended that all gadget HTML and script files be saved with UTF-8 character encoding.
The following steps can be taken to ensure the encoding of these files:
Open the file in Notepad.
On the File menu, click Save as...
In the Save as dialog box, confirm that the value in the Encoding drop-down is UTF-8.
If the value in the Encoding drop-down is not UTF-8:
In the Encoding drop-down, select UTF-8.
Click Save to overwrite the existing file.
Repeat this process for all gadget HTML and script files.
注意:
1. 调试的文件地址 C:\Users\用户名\AppData\Local\Microsoft\Windows Sidebar\Gadgets
2. 设置IE后,重启IE,调试。
相关文章推荐
- Gadgets 侧边栏小工具 跟踪调试方法
- Gadgets 侧边栏小工具 跟踪调试方法
- jvm 常用调试工具和设置jvm GC方法和指令
- VS2012/2013(简称VS)Lua编辑和调试方面的工具------BabeLua的使用方法
- 【webservice】调试方法篇(一、调试工具)
- Bochs调试及相关仿真工具的使用方法
- ubuntu下linux内核源码阅读工具和调试方法总结
- Oracle存储过程单步调试方法(使用pl/sql developer工具)
- ubuntu下linux内核源码阅读工具和调试方法总结
- js调试工具console.log()方法查看js代码的执行情况
- 互联网开发常用调试工具介绍及使用方法
- 调试工具Firebug的使用方法
- 错误的概念与处理 调试原理、工具和方法
- web前端调试工具及方法
- [转]HTTP调试工具:Fiddler的使用方法介绍
- [转】:Android调试工具及方法
- Unix调试工具dbx使用方法
- 调试工具Firebug的使用方法
- .NET应用程序调试—原理、工具、方法
- Android调试工具及方法