简体   繁体   English

为什么 Visual Studio 2005 不能调试我的 JavaScript 代码?

[英]Why will Visual Studio 2005 not debug my JavaScript code?

In this very simple ASP.NET application, Visual Web Developer 2008 Express CAN debug the JavaScript code fine, but the full version of Visual Studio 2005 CANNOT debug it , namely: when I click on a line in the main.js file it gives me a red circle with a question mark on it, the mouse hover revealing: "This break point will not be reached, no symbols were loaded for this document." In this very simple ASP.NET application, Visual Web Developer 2008 Express CAN debug the JavaScript code fine, but the full version of Visual Studio 2005 CANNOT debug it , namely: when I click on a line in the main.js file it gives me a red圆圈上有一个问号,鼠标 hover 显示:“这个断点不会到达,没有为这个文档加载任何符号。”

What do I have to do to my Visual Studio 2005 so that it debugs JavaScript code like my Visual Web Developer 2008?我必须对我的 Visual Studio 2005 做些什么才能像我的 Visual Web Developer 2008 那样调试 JavaScript 代码?

Default.aspx:默认.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestJavascriptDebugging2005._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
            <script type="text/javascript" src="javascript/main.js"></script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <p>This is HTML and <script type="text/javascript">test()</script>.</p>
                <p><button onclick="doIt(this)">Test</button></p>
            </div>
        </form>
    </body>
</html>

javascript/main.js: javascript/main.js:

function test() {
    document.write("this is from javascript code2");
}

function doIt(element) {
    alert("This is the javascript function2.");
}

Check if the following things are followed:检查是否遵循以下事项:

i.一世。 Enable script debugging in IE.在 IE 中启用脚本调试。

ii. ii. Open the client side script in the script explorer, and there you are happy debugging.在脚本资源管理器中打开客户端脚本,您就可以愉快地调试了。

For details on how to accomplish this, please go through the following link from which I originally picked up this trick.有关如何完成此操作的详细信息,请通过以下链接 go 我最初从中获得了这个技巧。

  1. Debugging client javascript in VS2005.在VS2005中调试客户端javascript
  2. A Kb from Microsoft explaining the same.来自 Microsoft 的Kb解释了相同的内容。

Integrated JavaScript debugging is a new feature of VS2008 - or at least, it's much improved ...集成 JavaScript 调试是 VS2008 的一个新特性——或者至少,它有了很大的改进......

If you search for "visual studio 2008 new features javascript debugging" you'll get lots of informative hits.如果您搜索“visual studio 2008 新功能 javascript 调试”,您将获得大量信息。

It's not unreasonable for a newer version of an IDE (even the Express edition) to have more features than an older version.较新版本的 IDE(甚至是 Express 版本)拥有比旧版本更多的功能并非不合理。

EDIT: Although JavaScript debugging was present in VS2005, it's better integrated in VS2008, and one of the new features is the ability to place breakpoints in JS code.编辑:虽然 JavaScript 调试出现在 VS2005 中,但它更好地集成在 VS2008 中,并且新功能之一是能够在 JS 代码中放置断点。

To be clear, Visual Studio 2005 does support JavaScript debugging.需要明确的是,Visual Studio 2005 确实支持 JavaScript 调试。 It just isn't able to resolve break points set on files with lines in source scripts in the browser.它只是无法解析在浏览器中源脚本中包含行的文件上设置的断点。

In Visual Studio 2005 you can place the debugger directive in the JavaScript code at the point you want to break.在 Visual Studio 2005 中,您可以将debugger指令放置在 JavaScript 代码中您想要中断的位置。 From there you can open the Scripts Explorer window and set break points in the source scripts (as seen from the browsers perspective).从那里您可以打开 Scripts Explorer window 并在源脚本中设置断点(从浏览器的角度来看)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM