Debugging applications in virtual machines with VMware Workstation 7 and Visual Studio 2008 SP1

Can be a hassle, that’s why I’m writing this post for you:

First of all some prerequisites:

  • VMware Workstation 7 (6.5 probably will be the same)
  • A VM, XP / Vista / 7, whatever you want
  • Visual Studio 2008 SP1

Second of all: VMware can be a little cryptic with it’s error messages so stay calm!

We start by having our sample application we want to run on the VM:

<screenshot>

Next we click the wrench tool on the VMware toolbar in Visual Studio:

Click the wrench tool

This opens the following dialog:

Virtual Debugger Configuration Pages

For your convenience I highlighted the settings you need to change.

The following order is not the order in the window, but the order that seems the most understandable in my opinion:

Virtual Machine: The VM you want to debug into, just select a suitable vmx.

Remote Debug Monitor Path: The path to Remote Debugger folder on the host computer NOT on the guest! So for 32-bit debugging that would be:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86\msvsmon.exe

Replace x86 with x64 if you require 64-bit debugging.

Shared Folders: This one is not used

Guest Command: The command to be executed on the guest to start the application. This one was quite the hassle for me. If you leave it on the standard it will result in the following (cryptic) error:

A valid executable name has not been specified in Debugger settings. You can change this in Project > Properties > Debugging.

So instead of leaving it on default you enter this;

\\vmware-host\Shared Folders\test\application.exe

Please replace application.exe to the name of your executable!

The last item, Guest Logon Credentials, is the easiest. This should be the username and password you use to log in to the VM.

Next up is setting the shared folder between the guest and the host.

While I tried this with the Shared Folder Item in the window we just filled in, I just can’t seem to get it to work. So I bypassed this.

Go to the settings of the VM (in VMware Workstation –> VM –> Settings (CTRL+D)):

image 

On the second tab, you take shared folders, and click add (as pointed on the picture).

On the wizard I would suggest opening the shared folder in the debug folder of your application and name the shared folder ‘test’

image

Enable the share in the following window, and make it read-write.

Now we can start the debugging from Visual Studio. The application will then be started through the shared folder we just created.

This entry was posted in .NET, Programming. Bookmark the permalink.
  • http://dirk.forbiddendream.be Dirk Schuermans

    Nice, this should come in handy when testing application compatiblity on all the different Windows OS’es

  • http://cyb3rh4xter.wordpress.com Fredrik Blomqvist

    Awesome thx!

  • sxwd

    Thank you very much. It helps me a lot

  • Farrukh

    Hi
    Thanks for this useful info. I’m interested to debug my dll which I used to load in AutoCad 2012. On my machine, I have a visual studio project which launch AutoCAD and then I Load my dll in it using Netload command and when it reached my breakpoint it stops there and I start the debugging thing.

    Any clue how to achieve this if I want to run AutoCAD in VM and source code on my host ?

    Thanks a bunch

  • Calvin

    Hi Kristof,
    Thanks, this blog help me a lot. But my situation is a little different. I’m working on a Office addin, this project starts from an Office application, the Start Action of project properties is something like “C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE”. Now I want to debug this project in VM, but the question is that how to config Guest Comman to make the project start from Office application in VM?
    Thanks in advance and look forward hearing of you.

  • http://www.lebenengland.de Robert

    Finally! thank you man – tried every single solution on the web but your worked like a charm :)

  • Speedbones

    Thanks a lot tried to fix that cryptic Error Message for hours :a valid executable name has not been specified.