当启用“仅我的代码”时,Visual Studio 2015 JavaScript调试不会捕获未处理的异常

时间:2022-03-12 20:44:25

Since the entire team has upgraded to Visual Studio 2015, the debugger no longer breaks on unhandled exceptions in JavaScript. However 1 of the 4 machines works fine and we're guessing this is because it's on IE10 and the rest of us are on IE11.

由于整个团队已升级到Visual Studio 2015,因此调试器不再中断JavaScript中未处理的异常。然而,4台机器中的1台工作正常,我们猜测这是因为它在IE10上,我们其余的都在IE11上。

Anyway, to cover the obvious stuff:

无论如何,要涵盖明显的东西:

  • All settings are identical between all machines, including the mycode.default.wwa.json in the JavaScript > JustMyCode folder in the Visual Studio 2015 installation directory

    所有设备之间的所有设置都相同,包括Visual Studio 2015安装目录中JavaScript> JustMyCode文件夹中的mycode.default.wwa.json

  • The default settings on the new Exception Settings window match the Exception settings in the old modal window from 2012

    新“例外设置”窗口中的默认设置与2012年旧模式窗口中的“例外”设置相匹配

So to reproduce the problem, we just write any old bit of dodgy code in an external JS file (note that script blocks on the page itself are caught correctly):

因此,为了重现这个问题,我们只需在外部JS文件中编写任何旧的狡猾代码(注意页面本身的脚本块被正确捕获):

ViewModel.js:

ViewModel.js:

function something() {
   foo();
}
something();

When JustMyCode is enabled, foo() will not be caught as an unhandled exception by the debugger. As soon as JustMyCode is disabled, the exception will be caught fine. So yeah, we can workaround this problem, but as soon as that's disabled, we lose actual .Net debugging.

启用JustMyCode时,调试器不会将foo()作为未处理的异常捕获。一旦JustMyCode被禁用,异常将被捕获。所以是的,我们可以解决这个问题,但是一旦禁用,我们就会失去实际的.Net调试。

Has anyone experienced this problem and/or found a solution? I've tried adding *.js to the MyCode section inside of the mycode.default.wwa.json file and I've also logged a bug on Connect, but I don't expect a fast answer from Microsoft on the matter.

有没有人遇到过这个问题和/或找到了解决方案?我已经尝试将* .js添加到mycode.default.wwa.json文件中的MyCode部分,并且我还记录了Connect上的一个错误,但我不希望微软就此事快速回答。

Edit: So this only seems to happen when there's a query string on the end of the JS file, e.g. site.js?V=1234. If you remove the query string then the debugger catches exceptions as it did in Visual Studio 2012. Submitted a new repro and demo project to Microsoft.

编辑:所以这似乎只发生在JS文件末尾有一个查询字符串时,例如site.js?V = 1234。如果删除查询字符串,则调试器会捕获异常,就像在Visual Studio 2012中一样。向Microsoft提交了一个新的repro和演示项目。

1 个解决方案

#1


0  

I came across this, and in my case, it was related to domain names in my project settings. The fix was to make sure that the domain of the URL in IE is the same as the domain in the Project Settings/Web/Startup URL.

我遇到过这个问题,就我而言,它与我项目设置中的域名有关。修复是为了确保IE中URL的域与项目设置/ Web /启动URL中的域相同。

For example:

例如:

URL IN IE: http://www.yourproject.local

URL IN IE:http://www.yourproject.local

Startup URL in project settings: http://www.yourproject.local

项目设置中的启动URL:http://www.yourproject.local

If the two domains are different then Visual Studio handling of JavaScript exceptions is broken.

如果这两个域不同,那么Visual Studio对JavaScript异常的处理就会被破坏。

EDIT: I just saw your edit about query strings. So this may be related to your problem. Can you make sure domain names aren't mismatched?

编辑:我刚看到你对查询字符串的编辑。所以这可能与您的问题有关。你能确保域名不匹配吗?

#1


0  

I came across this, and in my case, it was related to domain names in my project settings. The fix was to make sure that the domain of the URL in IE is the same as the domain in the Project Settings/Web/Startup URL.

我遇到过这个问题,就我而言,它与我项目设置中的域名有关。修复是为了确保IE中URL的域与项目设置/ Web /启动URL中的域相同。

For example:

例如:

URL IN IE: http://www.yourproject.local

URL IN IE:http://www.yourproject.local

Startup URL in project settings: http://www.yourproject.local

项目设置中的启动URL:http://www.yourproject.local

If the two domains are different then Visual Studio handling of JavaScript exceptions is broken.

如果这两个域不同,那么Visual Studio对JavaScript异常的处理就会被破坏。

EDIT: I just saw your edit about query strings. So this may be related to your problem. Can you make sure domain names aren't mismatched?

编辑:我刚看到你对查询字符串的编辑。所以这可能与您的问题有关。你能确保域名不匹配吗?