Javascript 在 Visual Studio 11 中使用 Chrome 启用脚本调试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10740397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 02:44:09  来源:igfitidea点击:

enable script debugging using Chrome in Visual Studio 11

javascriptasp.net-mvcdebugginggoogle-chromevisual-studio-2012

提问by eddo

I have a MVC 4 web Application with some javascript which is working fine with Internet Explorer and gives an issue with Chrome.

我有一个带有一些 javascript 的 MVC 4 Web 应用程序,它在 Internet Explorer 中运行良好,但在 Chrome 中出现了问题。

I was thinking to debug using Chrome as a browser in Visual Studio 11, which can be selected from the debug dropdown: the issue is that I cannot figure out how to enable script debugging : when I debug the breakpoint are disabled with the usual warning

我想在 Visual Studio 11 中使用 Chrome 作为浏览器进行调试,可以从调试下拉列表中选择:问题是我无法弄清楚如何启用脚本调试:当我调试时,断点被禁用并显示通常的警告

No symbols have been loaded for this document

尚未为该文档加载任何符号

I know I might debug scripts directly in Chrome, but I prefer going consistent using Visual Studio, since it involves stepping into several lenghty js libraries.

我知道我可能会直接在 Chrome 中调试脚本,但我更喜欢使用 Visual Studio 保持一致,因为它涉及到几个长的 js 库。

I can see from a previous postthat with Visual Studio 2008 that was not possible: does anyone know a way to do that with Visual Studio 11?

我从之前一篇文章中可以看出,使用 Visual Studio 2008 是不可能的:有没有人知道使用 Visual Studio 11 做到这一点的方法?

PS: attaching the Chrome process does not help as the debugging mode is 'Native' instead of 'Script'

PS:附加 Chrome 进程没有帮助,因为调试模式是“本机”而不是“脚本”

PSII: I also tried to attach Chrome using the Attach to: Script Codeoption in the Attach.. menu (this switches the Debugging mode to Script) but that does not help as well.

PSII:我还尝试使用Attach to: Script CodeAttach.. 菜单中的选项附加 Chrome (这会将 Debugging 模式切换为Script),但这也无济于事。

回答by Blowsie

You simply can't do this. Visual Studio only connects with IE in this way.

你根本无法做到这一点。Visual Studio 只能通过这种方式与 IE 连接。



Chrome does of course have its own debugging tools that you can use, but you won't be able to get your stops inside of Visual Studio as you may hope.

Chrome 确实有自己的调试工具供您使用,但您将无法像您希望的那样在 Visual Studio 中停留。



There is a whole load of answered / unanswered / incorrectly answered questions all over the web and SO on the matter.

整个网络上都有大量已回答/未回答/未正确回答的问题,因此就此事而言。

回答by July.Tech

Here are the steps that worked for me in Visual Studio 2015 (should work in earlier versions as well):

以下是在 Visual Studio 2015 中对我有用的步骤(应该也适用于早期版本):

Start chrome in remote debug mode: chrome.exe --remote-debugging-port=9222 Attach Visual Studio: "Debug" -> "Attach to Process..." -> select the chrome instance

在远程调试模式下启动 chrome:chrome.exe --remote-debugging-port=9222 附加 Visual Studio:“调试”->“附加到进程...”-> 选择 chrome 实例

All credit goes to: http://lostindetails.com/blog/post/JavaScript-debugging-in-VisualStudio-with-Chrome

所有功劳归于:http: //lostindetails.com/blog/post/JavaScript-debugging-in-VisualStudio-with-Chrome