Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017 Chrome JavaScript Debuging - Not hitting break point

I have installed VS2017 and trying out the new stuff they added. One of the nice things is chrome JS debugging but I can't seem to hit a break point.

I created a new .net core website (.net core 1.1) and add the following function into the site.js file

function test() {
var a = "message";

console.log(a); };

I then add a break point on the line "var = a..."

run the website - it opens a new chrome window and attaches to the process like it should. I then press F12 and call test() but no break point is hit it just outputs to the console.

One thing that is also in the console window is the following message -

Browser Link: Failed to invoke return value callback: TypeError: Cannot read property 'files' of null

however i also get this message when trying it out in IE11 and it does hit the break point in IE

I have updated my chrome to the latest version - 57.0.2987.98 I am running windows 10 pro (fully up to date)

site.js code

Chrome Console Output

Any ideas what it might be?

Update

I have tried on the following computers -

  1. My home PC (Windows 10 Pro)- has VS2015 and VS2017 on it
  2. Work PC (Windows 8.1 Pro) - also has VS2015 and VS2017 on it
  3. With in my work PC - (new build) HyperV VM (Windows 8.1 Pro) - just VS 2017 on it

All 3 failed to hit the break point

Whats odd is someone else at work is able to make it work without an issue.

like image 830
Thomas James Avatar asked Mar 09 '17 21:03

Thomas James


People also ask

How do you set a breakpoint in Visual Studio 2017?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint.

Why is JavaScript so hard to debug?

What makes JavaScript great is also what makes it frustrating to debug. Its asynchronous nature makes it easy to manipulate the DOM in response to user events, but it also makes it difficult to locate problems.

Can you use breakpoints in JavaScript?

Setting BreakpointsIn the debugger window, you can set breakpoints in the JavaScript code. At each breakpoint, JavaScript will stop executing, and let you examine JavaScript values. After examining values, you can resume the execution of code (typically with a play button).


1 Answers

As soon as you hit F12 in chrome, which opens the Chrome Dev Tools, it kills the client-side debugging session.

See: https://blogs.msdn.microsoft.com/webdev/2016/11/21/client-side-debugging-of-asp-net-projects-in-google-chrome/

Perhaps try executing automatically... e.g... (untested)

(function test() {
   ...
})();
like image 91
Mark van Proctor Avatar answered Oct 23 '22 04:10

Mark van Proctor