Gadgets 侧边栏小工具 跟踪调试方法

原文地址: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

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 a try...catch block. 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.

Internet Options in Windows Internet Explorer

Click the Advanced tab and verify that both Disable script debugging check boxes are not selected.

IE Tools|Options|Advanced|Disable script debugging

If using Visual Studio for debugging, click Tools, select Options, and ensure that Just-In-Time debugging is enabled for Script:

Just-In-Time debugging for script in Visual Studio

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 debugger statement is executed the Visual Studio Just-In-Time Debugger dialog will prompt you to open a registered debugger:

The Visual Studio Just-In-Time Debugger dialog

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:

Stepping through the code in the debugger

Tips
Character Encoding

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:

  1. Open the file in Notepad.
  2. On the File menu, click Save as...
  3. 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:

  1. In the Encoding drop-down, select UTF-8.
  2. 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,调试。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Industrial Gadgets ActiveX Pro是一个应用于工业制造领域的软件程序。它是一个ActiveX控件,可嵌入到其他的软件或系统中使用。 该软件主要提供了一些列实用的工业操作功能,例如数据采集、控制系统、传感器操作、数据处理等等。这些功能的实现完全基于最新的工业自动化技术,能够快速、高效地完成各种生产过程和操作流程。 该软件还拥有一个友好易用的用户界面,帮助工业制造行业的用户轻松地操作和管理生产工厂、设备和工具。此外,该软件还提供了一系列易用的工业报表功能,帮助用户汇总和分析生产数据,以改进和优化生产流程。 综上所述,Industrial Gadgets ActiveX Pro是一款非常优秀的工业自动化软件,为工业制造领域提供了高效、实用的自动化控制和数据处理方案。它的特点在于其稳定的性能和兼容性,可以广泛应用于各种工业制造领域。 ### 回答2: Industrial Gadgets ActiveX Pro是一种工业控制组件,可以用于创建高效、可靠的控制系统,并提供多种插件和工具来实现灵活的数据监测、设备控制、数据采集、通讯结构等。此组件可以通过工业增强版的ActiveX控件接口,实现设备间的数据交互,支持多种编程语言和插件,可用于工业自动化、智能家居、物联网等领域。此外,该组件还提供了丰富的数据报表,支持实时、历史数据查询、统计分析,方便工程师进行数据处理和工程设计。总之,Industrial Gadgets ActiveX Pro具备强大的功能和灵活的扩展性,可为工业控制系统和智能化设备提供全方位的支持。同时,该组件还提供了易用的开发工具和平台,帮助用户快速开发应用程序和项目,提高工程效率,降低开发成本,是现代控制系统中不可缺少的一部分。 ### 回答3: Industrial Gadgets ActiveX Pro是一种用于开发和设计工业控制系统的软件工具。它可以通过使用ActiveX控件来实现用户界面与工业设备之间的通信,该工具可以帮助开发人员加速开发过程,减少开发成本。此外,它还提供了用于调试和单元测试的工具,以确保所开发的系统能够正常运行并满足工业要求。 与传统的控制器编程相比,Industrial Gadgets ActiveX Pro提供了更快的响应时间和更高的精度。开发人员可以使用它来实现各种功能,如数据采集、监控和调节控制等模块。此外,它还可以与其他软件和硬件组件进行无缝集成,以满足各种工业自动化应用程序的要求。 总之,Industrial Gadgets ActiveX Pro是一款功能强大且易于使用的软件工具,可帮助开发人员迅速构建高效、可靠、易于维护和管理的工业控制系统。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值