zoukankan      html  css  js  c++  java
  • 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,调试。

    冯瑞涛
  • 相关阅读:
    爬取豆瓣影评1寻找json格式的电影信息
    打开SSM项目后打开tomcat找不到路径问题
    爬取豆瓣影评2完整代码
    打开SSM项目无法启动问题补充
    使用python制作国民经济行业国标的json格式
    MVC前端AJAX向后端传递数据——正常传值
    国民经济行业维度清洗,将数据清洗成标准的四级信息。
    使用vue的element组件网址
    Mybais中sql语句的抽取
    mybatis找不到mapper_Springboot整合Mybatis
  • 原文地址:https://www.cnblogs.com/finehappy/p/1522023.html
Copyright © 2011-2022 走看看