windows-desktop-gadgets – 在没有Visual Studio的情况下调试Windows边栏小工具

我正在尝试在不使用Visual Studio的情况下创建侧边栏小工具.我一直在寻找调试它们的方法,但是一切都说Visual Studio JIT调试器是唯一的方法.

有没有人能够在没有Visual Studio的情况下调试侧边栏小工具?

多年来,我没有使用Visual Studio来处理小工具.有几种方法可以在没有它的情况下调试小工具,只是没有那么广泛.例如,您不能使用调试器;命令没有附加到进程的适当调试器.你可以做的是使用像 DebugView这样的程序来捕获 System.Debug.outputString()方法输出的消息:
function test ()
{
    System.Debug.outputString("Hello,I'm a debug message");
}

这允许您在代码的某些阶段输出变量转储和其他有用的信息,因此您可以随意跟踪它.

作为替代方法,您可以使用window.prompt()滚动自己的调试/脚本暂停消息.对于小工具已禁用alert()并且覆盖confirm()以始终返回true,但它们必须忽略prompt().

function test ()
{
     // execute some code

     window.prompt(someVarToOutput,JSON.stringify(someObjectToexamine));

     // execute some more code
}

如果要在代码执行期间检查对象的状态,JSON.stringify()方法确实有帮助.

您也可以使用VBScript MsgBox()函数代替window.prompt:

window.execScript( //- Add MsgBox functionality for displaying error messages
      'Function vbsMsgBox (prompt,buttons,title)\r\n'
    + ' vbsMsgBox = MsgBox(prompt,title)\r\n'
    + 'End Function',"vbscript"
);

vbsMsgBox("Some output message",16,"Your Gadget Name");

最后,您可以使用window.onerror事件处理程序捕获脚本中的所有错误.

function window.onerror (msg,file,line)
{
    // Using MsgBox
    var ErrorMsg = 'An error has occurred'+(line&&file?' in '+file+' on line '+line:'')+'.  The message returned was:\r\n\r\n'+ msg + '\r\n\r\nIf the error persists,please report it.';
    vbsMsgBox(ErrorMsg,"Your Gadget Name");

    // Using System.Debug.outputString
    System.Debug.outputString(line+": "+msg);

    // Using window.prompt
    window.prompt(file+": "+line,msg);        

    // Cancel the default action
    return true;
}

window.onerror事件甚至允许您输出发生错误的行号和文件(仅适用于IE8).

祝你好运调试,并且在发布你的小工具时记得不要离开任何window.prompts或MsgBoxes!

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...