One of the ancillary benefits of our Vista Gadget breaking and my email filling up with complaints was that I learned how to debug a Vista Gadget in Visual Studio, so I’m sharing the wealth with everybody.
Vista Gadget中断和我的电子邮件充满投诉的附带好处之一是,我学会了如何在Visual Studio中调试Vista Vista小工具,因此我与所有人分享了财富。
For this exercise you’ll need a copy of Visual Studio 2005 and a broken Vista Gadget, but you can probably adapt it to work with a different tool if you try.
对于本练习,您将需要一个Visual Studio 2005副本和一个损坏的Vista小工具,但是如果尝试尝试,则可以使其适应于其他工具。
Critical Step: Enable Script Debugging
关键步骤:启用脚本调试
Open up Internet Explorer’s Options panel, find the Advanced tab and uncheck the boxes for “Disable script debugging”.
打开Internet Explorer的“选项”面板,找到“高级”选项卡,然后取消选中“禁用脚本调试”框。
After you are done debugging you’ll probably want to turn this off, as it can get quite annoying while browsing.
调试完成后,您可能需要关闭此功能,因为浏览时会很烦人。
Open Your Gadget Code
打开小工具代码
After installing your gadget, Windows will unpack and copy the files to a folder in your user profile. We’ll need to find this folder and open the javascript file that makes up the logic for your gadget.
安装小工具后,Windows将解压缩文件并将其复制到用户配置文件中的文件夹中。 我们需要找到此文件夹,然后打开构成小工具逻辑的javascript文件。
Just paste the following into the Explorer address bar:
只需将以下内容粘贴到资源管理器地址栏中:
%LOCALAPPDATA%\Microsoft\Windows Sidebar\Gadgets
%LOCALAPPDATA%\ Microsoft \ Windows边栏\小工具
You’ll see a list of directories for all the gadgets installed into your profile. Open up the main javascript file in Visual Studio.
您会看到配置文件中安装的所有小工具的目录列表。 在Visual Studio中打开主要的javascript文件。
Attach to Sidebar Process
附加到侧边栏流程
Next we’ll need to attach to the specific sidebar process for your gadget. (Make sure your gadget is running before you do this step)
接下来,我们需要为您的小工具附加特定的侧边栏流程。 (执行此步骤之前,请确保您的小工具正在运行)
Go to Tools \ Attach to Process or hit Ctrl+Alt+P to bring up the dialog.
转到“工具” \“附加到进程”或按Ctrl + Alt + P弹出对话框。
Now you should look for a process named “sidebar.exe” with the title set to the name of your gadget, and then click the Attach button.
现在,您应该查找一个名称设置为小工具名称的名为“ sidebar.exe”的进程,然后单击“附加”按钮。
For a close-up view, you can see that the gadget is running under a separate process from the main sidebar, but the title is set to “How-To Geek”.
对于特写视图,您可以看到该小工具在与主边栏不同的进程下运行,但是标题设置为“ How-To Geek”。
Now comes the critical step… click to set a breakpoint just to the left of the white area…
现在到了关键步骤…单击以在白色区域的左侧设置一个断点…
If all goes well, you will immediately be taken to a new file named something like x-gadget:///main.js and your debugging tools will become active as soon as the breakpoint is hit.
如果一切顺利,您将立即被带到一个名为x-gadget:///main.js之类的新文件,并且在遇到断点时,调试工具将立即激活。
Note that you can’t modify this file, but you can use the Immediate Window to test out any code in real-time.
请注意,您不能修改此文件,但是可以使用“即时窗口”实时测试任何代码。
Important Notes
重要笔记
Happy debugging!
调试愉快!