Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Visual Studio debugging to work when running in Parallels

I've got a Windows 7 machine set up on Paralells.
Everything is working fine. Can access internet from IE or other browsers on my Parallels.

However, when trying to debug a web application in Visual Studio 2010 (by pressing F5 for example) then my default browser in OSX launches, which is great, with localhost:4243 (or whatever port Cassini has allocated on my vm)

Naturally, this doesn't find anything...

What do I need to do to either my parallels vm, or the settings on OSX to get debugging working? ie- my mac talking to the vm?

like image 668
Alex Avatar asked Jul 10 '12 21:07

Alex


1 Answers

Make sure you are on the same network.
Use IIS.
Like so:

Your Win-machine has a name, let's say it's called "myWin7machine". Change "localhost:4243" to "myWin7machine:4243" in the browser.

If this doesn't work (well... it shouldn't) you might have the firewall on or the network not bridged. Let's start with the bridging.

Time to check some basics - be on the same network

Check your IP address. It's "ipconfig" on the Win machine and "ifconfig" on the mac; both run from the command prompt. The IP address should be something like 10.4.... or 192.168... on both. The important thing is that only the last number is different. (this is technically not correct but works for 99% of the cases) If they are equal (except the last) you are bridged - which means both machines are on the same network. If they differ too much you had running the Win machine's network "inside" the Mac's. Go to the settings for Parallels (in windows: move your mouse to the top to show Parallel's menu and go to Devices->Network and something "(bridged)". Wait until the balloons disappear and check ipconfig again.

Check that you can ping the Win machine from the Mac. Ping functionality might be turned off in the Win machine but probably isn't.

Now we know we are on the same network.

Still doesn't work

Can you do http://myWin7machine:4243 from the mac? Well.. you shouldn't be able to.

Can you do it from the Win machine? You should.

IIRC Cassini doesn't talk to strangers. I.e. it doesn't talk to anything but localhost.
If I am wrong - just open port 4243 in the firewall on the win machine and you should be good to go.

But otherwise...
Time to change web server.

Install IIS on the win machine.

In the Mac: surf to http://myWin7machine and see the IIS7 logo show.
If you don't you have a firewall issue. Open port 80. Try again.

If you have come this far then you can surf from the Mac to the IIS on the Win machine.

Time to set up your VS solution

Open the IIS admin GUI. Create a new Site. Let's say you call it MyTestSite. (you can always rename it later) Point it to your VS solution's web. Typically the same folder as web.config resides in. On the win machine: try surfing to "http://localhost/MyTestSite". Your site should show up. You might get an Apppool error.

Now try http://myWin7machine/MyTestSite on the Mac. It should work.

ROCK!

Time to set up debugging in VS

For debugging in IIS you have to connect to the process. In Win7 it requires elevated privileges so either you restart VS as admin or you try to connect and VS will do it for you.
The menu in VS is Debug->Attach to process and you choose w3wp.exe.

This is how you debug faster anyway - by connecting. Restarting your web for every debugging session is a waste of time.
To make connecting faster - use ctrl-alt-p and the continue with using the keyboard.
To make connecting even faster use a macro.
There is more info in these 4 articles: http://www.selfelected.com/tag/iis/
Set a breakpoint. Refresh your browser and the breakpoint should be hit.

Time to hack some code

Good luck!

like image 197
LosManos Avatar answered Sep 24 '22 18:09

LosManos