質問

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?

役に立ちましたか?

解決

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!

他のヒント

I'm using Windows 10, VS 2015, Parallels 11 on iMac with OS X El Capitan (10.11.5). The following are the steps that worked for me:

On Windows side:

  1. Get the IP (run ipconfig command in command window)
  2. Get the host name (run hostname command in command window)
  3. In control panel look for Windows Firewall -> Advanced Settings and add a new inbound rule and a new outbound rule. For both make sure you select Port, Allow Connection, TCP and specific IPs. I added a range of IPs 45000 - 45999 but you can select the range you like.

In Visual Studio:

  1. Look for project properties and under web section change Server settings to look something like this. enter image description here Instead of "winmac" you will use the host name found in "Windows Side - Step 2". The port can be any number inside the range you setup for your firewall rules.

On Mac OS side:

  1. Update /etc/hosts file. At the end of the file add the IP and host name that we found on steps 1 and 2 of the "Windows side" section. When you finish this step the file should like something similar to this.enter image description here

Ready to debug:

Now you can start debugging in your Mac from Visual Studio. Make sure that before start the debugging process you select "Open In Mac" option (instead of Chrome or IE in your debugging options in visual studio).

enter image description here

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top