2

When running an asp.net web site in Visual Studio 2017 on my local host, using IE 11, and debugging javascript, Visual Studio has a very convenient feature where we can put the statement "debugger;" in a javascript file, and when that statement is hit it is like hitting a normal breakpoint in Visual Studio. One can then step through the javascript code in Visual Studio.

Sometimes VS automatically uses the existing instance of Visual Studio (the instance I am using to run the web site) to step through the javascript. This is very convenient, and I would like this to happen every time.

However, sometimes I see a prompt where VS forces me to select a new instance of Visual Studio. The prompt looks like this:

enter image description here

I want to stress, there is not an unhandled exception in my javascript code. This JIT prompt is occurring solely because of the "debugger;" statement. When I go through the rigmarole of opening a new instance of VS it brings me to the "debugger;" statement and I merrily step through my javascript.

Disabling JIT debugging in Visual Studio 2017 does not fix this issue; with JIT disabled I still [sometimes] get the JIT prompt, the sole difference is that the prompt does not list VS 2017 as an option.

There does not seem to be any rhyme or reason: sometimes it automatically uses the existing instance, sometimes it throws this prompt. It will treat the exact same javascript differently, sometimes debugging it in the already-open VS, sometimes forcing me to open a new instance.

I'd like to avoid the prompt and always use the existing instance of Visual Studio, because it is faster than waiting for a new instance of VS to open and because the debugging experience is superior (e.g., I can hover over variables and see there value if I use the existing instance, whereas with a new instance I must open a watch window).

Is there any way to force VS to always use the existing instance?

Tom Regan
  • 3,580
  • 4
  • 42
  • 71
  • Would appreciate if the down-voters left a comment. – Tom Regan Sep 14 '17 at 18:54
  • Please check your VS 2017 version first. The latest version should be 15.3.4. The please create a simple html page and add some simple Javascript code to check whether this problem only occurs with your current Javascript code. In addition, please check whether you have installed any third part extensions which effect your Visual Studio Debugger. – Weiwei Sep 15 '17 at 02:40
  • @Wendy-MSFT, no 3rd party extensions. I'm at v15.3.3. When I create a simple html page with the "debugger;" statement it works the way I want it (it uses the existing instance of VS). Knowing that does not really help me though. It also works in my real application some of the time. I'd like it to work all the time, not just some of the time. I'm wondering if anyone knows what causes visual studio to show the "new instance" prompt some of the time. – Tom Regan Sep 15 '17 at 17:04
  • The simple html page works the way you wanted, I suspect there has other js exception in your code causes this issue. If possible, please share some js code snippet. I will test them in my side to check whether this problem is related to your code or not. – Weiwei Sep 18 '17 at 03:03
  • @Wendy-MSFT, there is no js exception. The js is fine; the debugger works fine; the statement "debugger;" works fine. The sole issue is that I do not want Visual Studio to [sometimes] prompt me to open a new instance of Visual Studio. I want it to always use the existing instance. The question is: why does Visual Studio [sometimes] prompt me to open a new instance? Why doesn't it always use the existing instance? – Tom Regan Sep 18 '17 at 12:47
  • @Tom Regan, Just-In-Time debugging launches Visual Studio automatically when an exception or crash occurs in an application that is running outside Visual Studio. If you really want to avoid it, you could disable this feature in your VS or debug your app and find the real reason: https://msdn.microsoft.com/en-us/library/5hs4b7a6.aspx. – Jack Zhai Sep 19 '17 at 10:25
  • @JackZhai-MSFT, I'm not trying to prevent debugging from occurring. I want to debug; I am inserting the "debugger;" statement into my javascript code because I want to set a breakpoint to start debugging. I just don't want Visual Studio to [sometimes] force me to launch another instance. I want it to always use the existing instance of Visual Studio. My question is, why does Visual Studio sometimes use the existing instance, and sometimes give me that JIT prompt and force me to launch another instance? – Tom Regan Sep 19 '17 at 12:41
  • @Tom Regan, To debug our apps, generally it really just use the existing instance of VS, but one issue is that apps meet certain issue during debugging, like the crashed issue or it has an unhandled exception on a server or others. JIT debugging will be called automatically: https://stackoverflow.com/questions/1893567/how-to-stop-just-in-time-debugging-messages-blocking-a-buildserver. So like my previous suggestion, you could disable JIT debugging, and just debug it using the default VS debugging, of course, you could enable Exception settings window under Debug menu which could help you. – Jack Zhai Sep 20 '17 at 10:23
  • @JackZhai-MSFT, you are assuming there is an unhandled exception in my javascript, but that assumption is wrong. I'm [sometimes] seeing the JIT prompt solely because of the "debugger;" statement in my javascript code. Sometimes Visual Studio brings me to the "debugger;" statement in my existing instance of Visual Studio; sometimes it shows me the JIT prompt and forces me to open a new instance of Visual Studio. Disabling JIT debugging in VS 2017 does not fix the problem, I still [sometimes] get the JIT prompt, the sole difference is that the JIT prompt does not list VS 2017 as an option. – Tom Regan Sep 20 '17 at 13:10
  • @Tom Regan, Since you have installed different VS versions in your machine, JIT debugging in VS2013 also was called automatically, if we really want to avoid it, we have to disable all of them. As you said that sometimes it has this issue, to really repro this issue, you could share a simple sample using one drive, I will download and debug it in my side. At least, we could know that whether it is related to the project itself or the VS IDE or others. – Jack Zhai Sep 21 '17 at 01:53
  • @JackZhai-MSFT, even though VS 2013 shows as an option in the prompt, it is not installed on my machine; I uninstalled VS 2013 before I installed VS 2017. So there is no way to disable VS 2013 JIT debugging. I'm not sure why VS 2013 shows in the prompt, probably the presence of some registry entry or folder that the uninstall failed to remove. – Tom Regan Sep 21 '17 at 13:13
  • Maybe you could check that whether there are other VS 2013 files in control panel like VS 2013 shell or others, or you could edit/delete the registry keys in your side, view the result. In IE browser, Tools > Internet Options > Advanced Tab, check Disable Script Debugging and check Disable Scribt Debugging (Other). – Jack Zhai Sep 22 '17 at 06:25
  • @Tom Regan, Do you resolve this issue now? If you get any latest information, please feel free to share it here:) – Jack Zhai Sep 26 '17 at 06:30
  • No change. Sometimes it uses the existing instance, sometimes it forces me to create a new instance. No rhyme or reason to it. I appreciate your suggestions, but what I really need to know is exactly how Visual Studio decides when to show that prompt vs. just use the existing instance. – Tom Regan Sep 26 '17 at 13:06

1 Answers1

0

I ran into the same problem in VS 2019 after a while. It looks like VS have this issue often. The solution is: Debug -> Attach to Process (Ctrl+Alt+P), select running process. It is harder, but allows to use the same instance of VS, and definitely faster then the new instance. After process ends, keep current VS window opened, and when you are ready to debug the same process again, hit Shift+Alt+P to reattach it.