14

I have Firefox as my default browser on my dev machine and when I start debugging from visual studio Firefox launches as I would expect and all the attributes of the experience are the same as IE except for one thing - when I close the browser. When using IE, when I close the browser visual studio will automatically shut down the debugger. When I close FF I do not get this behavior - does anyone know how to make this happen?

keithwarren7
  • 14,094
  • 8
  • 53
  • 74

4 Answers4

12

The reason for this behavior is very simple: Visual Studio attaches itself to the process to be debugged, and will drop out of run mode if it sees that process terminate. FireFox does not create a new process every time a window is launched: it reuses the existing process. IE is able to create a new one for each window (depends on option settings). If you already have FF running and you launch an app to be debugged, the app window is created in the existing process and VS attaches to that process. When you close the app window the process doesn't terminate because it is still active for the pre-existing windows. Next time it happens close all the other FF windows and you will see Visual Studio drop out of debug run mode. If there was a way to tell FireFox to create a new process for a new window then this problem would go away. I haven't found any reasonably reliable way to do that.

Mark
  • 219
  • 1
  • 3
  • I have experienced that when debugging an application using VS 2008 it opens a new FF window for each time F5 is pressed (debugging started). I wonder if it can use the existing opened FF window for debugging. – azamsharp Nov 19 '09 at 16:46
  • 2
    @Mark - I start debugging with Firefox not running at all (verified in Task Manager). Start debugging and Firefox starts. Kill Firefox (again, verified in Task Manager) and the debugger doesn't stop. – Emilio Mar 29 '10 at 03:59
9

To add to Mark's answer, you can setup a specific "debug" profile for firefox, and then change the project's properties/Web, select there "start external program" and browse to firefox.exe, and set commandline arguments to '-no-remote -P "MyDebugProfile" '.

To manage your profiles, start (from command-line) firefox like this:

c:\> <installation path of ff>\firefox.exe -profilemanager

There, you create a new profile (lets say "debug")

To start a new process of FF with this profile (i.e. what you set for VS):

c:\> <install path to ff>\firefox.exe -no-remote -P "debug" "http://mysite"

Note, that the "-P" parameter is case sensitive.

Community
  • 1
  • 1
Sunny Milenov
  • 21,990
  • 6
  • 80
  • 106
  • at the project Properties/Web tab, "Start Action" is set to "Start external program" and is pointed to the firefox.exe (FF 3.5), at "Command line arguments" I wrote(without brackets): [-no-remote -P "debug"]. "debug" is a profile previously created in FF using the -profilemanager argument. When I debug the project, it starts FF as it always did (FF is my default browser), and as it always did, if I close FF, VS continues debugging, the same way as if I STOP debugging, FF stay open... Obs.: post your answer at my question so I can accept it. – Tufo Mar 10 '10 at 22:13
  • @Tofu: please, verify with task manager how many (and what command line args) FF instances you have while debugging. You can check before you start the debugger, during the debugging, and after you stop. This will tell if VS starts a new process at all, and if it properly handles it. – Sunny Milenov Mar 11 '10 at 15:02
  • This works PERFECTLY and Sunny is the God :) I can't emphasize my enthusiasm more since I've always had this problem. +1, of course. Just to help a bit more, define a specific Development Server port (e.g. 51336) under project properties/Web so Command line arguments look like: -no-remote -P "debug" "http://localhost:51336/" – dpant Nov 28 '12 at 19:20
1

Right click on any .aspx page and choose the option "Browse With..." there you can setup the default browser

Rony
  • 9,331
  • 2
  • 22
  • 22
0

Try attaching the debugger to the FireFox process instead!

In VS (2008) select the Menu option Debug -> Attach to Process and then select firefox.exe - if you don't see this process you may have to ensure 'Show processes in all sessions' is checked.

I ran this and verified that it does work. I also verified that closing FireFox via app debug does not work, if you Firefox is set as the default browser in VS 2008.

D3vtr0n
  • 2,774
  • 3
  • 33
  • 53
  • 1
    I don't think this is doing what you think it is. – John Sheehan Nov 28 '08 at 02:05
  • I dont know, what do you think its doing? I ran it both ways, and if you attach the debugger via "ATTACH TO PROCESS" in the debug menu in Visual Studio, that does work. If you setup your default browser to be Firefox, through settings, it doesnt work. Use "attach to process", it works.... – D3vtr0n Dec 01 '08 at 06:16
  • 1
    Think about it carefully... If you're attaching it to the firefox process what code is being debugged? Usually when talking about debugging in visual studio and a web browser the scenario is debugging a web application. – Min Dec 02 '08 at 20:27