Taking Advantage of Microsoft Virtual PC 2007 for Developing and Maintaining .NET 1.1 and 2.0 Applications in Microsoft Windows Vista Writers: Ishita Prasad, Adam Cogan Technical Reviewer: David Klein Project Editor: None Designer: None Published: [Insert Date:MM YYYY] Updated: [Insert Date: MM YYYY] Applies To: Microsoft Windows Vista, Microsoft .NET Summary: This document details methods that are recommended when developing and maintaining Microsoft™ .NET™ 1.1 and 2.0 applications whilst upgrading to Microsoft™ Windows™ Vista. It particularly focuses on using Microsoft™ Virtual PC 2007™ to set up a virtualized environment to debug and modify these applications. Alternative methods such as remote debugging are also discussed. Copyright The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, email address, logo, person, place or event is intended or should be inferred. 2006 Microsoft Corporation. All rights reserved. Microsoft, Microsoft Access, Microsoft Exchange, Microsoft SQL Server, Microsoft SQL Server Reporting Services, Microsoft Visual Studio, Microsoft Visual Studio .NET, and Microsoft Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. Table of Contents ASSUMPTIONS.................................................................... 6 WHO SHOULD READ THIS ................................................... 7 ABOUT SSW AND THE AUTHORS ......................................... 7 ABOUT SSW AND THE AUTHORS ......................................... 8 ABSTRACT .......................................................................... 9 MICROSOFT WINDOWS VISTA IS HERE! ........................... 10 WHAT MAY STOP YOUR .NET APPLICATION FROM RUNNING IN MICROSOFT WINDOWS VISTA ..................................... 10 MICROSOFT VIRTUAL PC 2007 IS HERE! .......................... 12 Using Microsoft Virtual PC 2007 for Development .............................................................. 12 DEVELOPING AND MAINTAINING .NET FRAMEWORK 2.0 APPLICATIONS IN WINDOWS VISTA ................................ 13 SOLUTION 1 – USE MICROSOFT VISUAL STUDIO 2005 SP1 (RECOMMENDED)............. 13 Example – Web Application projects may not install in Windows Vista .......................... 14 SOLUTION 2 – USE MICROSOFT VIRTUAL PC 2007 ............................................ 14 DEVELOPING AND MAINTAINING .NET FRAMEWORK 1.1 APPLICATIONS IN VISTA ................................................. 15 SOLUTION 1 - TESTING ON WINDOWS VISTA WHILE DEBUGGING AND MODIFYING ON WINDOWS XP ....................................................................................... 15 SOLUTION 2 – USING MICROSOFT VIRTUAL PC 2007 (RECOMMENDED) ................... 16 The process of using Microsoft Virtual PC 2007 to debug applications ........................... 16 Installing Virtual PC 2007 ................................................................................ 16 Creating and Configuring the Virtual Machine........................................................ 17 Creating a new Virtual Machine................................................................................................... 17 Configuring the Virtual Machine .................................................................................................. 19 Installing the Guest operating System ................................................................ 19 Installing Applications in the Guest operating System .............................................. 21 Licensing Information .................................................................................... 21 Using Remote Debugging in Microsoft Virtual PC 2007 for Development (Advanced Users) ........................................................................................................................................ 21 Prerequisites ............................................................................................... 22 Configuring the Remote Debugging Monitor (msvsmon.exe) on Windows Vista ............... 22 Configuring the Host Debugging Machine (Windows XP in Virtual PC) .......................... 24 Configuring the Remote Debugging Machine (Windows Vista) .................................... 25 Starting the Remote Debugging Monitor on the Remote Debugging Machine (Windows Vista) ............................................................................................................... 27 Connecting to the Remote Machine in Visual Studio by Attaching to the Appropriate Process ............................................................................................................... 27 BEST PRACTICES FOR BUILDING YOUR VPC ENVIRONMENT AND TESTING AND DEPLOYING APPLICATIONS ............... 29 SUMMARY ......................................................................... 33 MORE INFORMATION........................................................ 33 Taking Advantage of Microsoft Virtual PC 2007 for Developing and Maintaining .NET 1.1 and 2.0 Applications in Microsoft Windows Vista Assumptions The information and steps in this paper are provided under the assumption that the following operating systems and software components are used: You are developing and testing on Microsoft Windows Vista You want to use Microsoft Visual Studio .NET 2003 or Visual Studio 2005 to develop your application Your application is developed using either .NET Framework 1.1 or .NET Framework 2.0 Who Should Read This This paper has been written for developers of .NET 1.1 and 2.0 applications who are considering migrating from their current operating system to Microsoft Windows Vista. Readers should be familiar with: Windows Vista and its new capabilities including its new security features Microsoft Virtual PC About SSW and the Authors This whitepaper is written by Adam Cogan and Ishita Prasad of Superior Software for Windows (SSW). SSW is a Sydney based consulting company specializing in .NET solutions for progressive businesses since 1990. SSW offers custom software solutions in ASP.NET, VB.NET, C#, SQL Server, Microsoft Exchange Server, Microsoft Access and Office 2003. Adam Cogan is the Chief Architect at SSW and is one of three Australian Microsoft Regional Directors in Australia who has been developing custom solutions for businesses across a range of industries as diverse as Government, financial, insurance and manufacturing since 1990 for clients such as Microsoft, Quicken, and the Fisheries Research and Development Corporation. Adam can be contacted at adamcogan@ssw.com.au. Ishita Prasad is a software developer who has extensive industrial experience in developing Microsoft solutions. In particular, she has an in-depth knowledge of the Microsoft suite of products, including Microsoft Windows Vista, Microsoft Virtual PC and .NET Windows Forms. Information in this whitepaper is based on our experiences and observations using Windows software. We welcome any feedback to info@ssw.com.au. Abstract Microsoft Windows Vista is the latest Operating System suite which offers a variety of new features and experiences that will benefit everyone, from the everyday user to the IT specialist. A number of significant improvements have been made to Windows Vista, the most significant of which are its enhanced security capabilities, allowing for a much safer and more stable operating environment. Although many measures have been taken to ensure application compatibility in Vista, the advanced security features can hinder the smooth migration progress from the current operating system to Windows Vista. A side-effect of this is that existing development tools, such as Microsoft Visual Studio 2005, may not be fully functional in Windows Vista. This paper assists developers in using alternative methods to continue the development and maintenance of their .NET 1.1 and .NET 2.0 applications, while ensuring a smooth migration process to Microsoft Windows Vista. This paper details: Microsoft Windows Vista and reasons why a developer’s .NET application may not be compatible with it A scenario a developer may encounter when trying to develop their .NET 2.0 application in Windows Vista Using Microsoft Visual Studio 2005 SP1 without Virtual PC to workaround problems which may occur A scenario a developer may encounter when trying to develop their .NET 1.1 application in Microsoft Windows Vista Testing the application on a Microsoft Windows Vista machine while debugging and modifying on a Microsoft Windows XP machine to work around this problem Using Microsoft Virtual PC 2007 to overcome both scenarios Using remote debugging in Microsoft Virtual PC 2007 This paper does not cover any issues developers may encounter with Microsoft SQL Server 2005. However developers may find these resources useful: You receive a warning message on the System Configuration Check page of the SQL Server 2005 Setup program on a computer that is running Windows Vista Beta 2 or a Server Core installation of Windows Server “Longhorn" Cumulative hotfix package (build 2153) for SQL Server 2005 is available Microsoft Windows Vista is here! Microsoft Windows Vista is an Operating System which builds on the existing features of Microsoft Windows XP and also introduces many new capabilities to provide a better user experience. This long awaited update introduces many new features including: An updated graphical user interface (Windows Aero) A restructured Start menu Easier accessibility to applications due to new searching features including a breadcrumb style of navigation A sidebar menu with gadgets for everyday activities Many new advanced security enhancements to guard the Operating System against viruses, malware and buffer overflows. Microsoft Windows Vista also introduces .NET Framework 3.0, which aims to make it significantly easier for developers to produce high quality applications. It consists of the following four components: Windows Presentation Foundation (WPF), is a new user interface subsystem and API based on XML and vector graphics, which will make use of 3D computer graphics hardware and Direct3D technologies. Windows Communication Foundation (WCF), is a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services. Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows. Windows CardSpace (WCS), is a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website. As well as this, Windows Vista also introduces several new core technologies and applications including ReadyBoost, which extends the disk caching capabilities of Windows Vista’s main memory when using a flash device, the Windows Image file based image format (.wim), ImageX and Windows Preinstallation Environment 2.0, all of which are resources designed specifically for deploying Windows Vista in corporate environments. What may stop your .NET Application from running in Microsoft Windows Vista Microsoft Windows Vista, offers a multitude of new and innovative features to enhance its security capabilities, thereby creating the most secure version of Windows yet. The enhanced security features have been applied whilst maintaining a high degree of application compatibility, so the majority of developers will feel no pain. The majority of applications developed within a Microsoft Windows XP environment will continue to run as normal in Microsoft Windows Vista. However, developers should still need to test that their application functions correctly in Windows Vista. The new features which may affect application compatibility include: User Account Control – is the most visible of the security enhancements. The main feature of User Account Control is that it reduces the computer’s vulnerability to viruses and instability by requiring applications to support Standard User privileges. User Account Control separates true administrative privileges from standard account tasks. Developers will need to shift the way they write their applications and access certain shared system files and registry keys. The Application Compatibility Toolkit can be used to diagnose some problems which may occur because of User Account Control. Windows Resource Protection – is another new feature which protects many system files and registry settings by limiting applications access to them and blocking major updates which may affect these protected resources. This can have a high impact, as applications trying to access these resources will be blocked and therefore fail to install. 64 bit version of Windows Vista – all 32 bit applications are fully supported on the 64 bit architecture of Windows Vista. However many 32 bit kernel drivers, 16 bit applications and 16 bit installers will not be compatible, as they are not supported by the 64 bit architecture. This means that legacy applications will be affected in the 64 bit version of Windows Vista. Applications that perform operating system version checks many applications while installing can perform operating system version checks and although the application may run perfectly well in Vista, since a specific version of the operating system is not found, these applications refuse to install. As seen above, the new features deliver a more secure and stable system for the end user. However, the other side is the applications that face compatibility issues under Windows Vista. To remedy these problems, Microsoft has released a vast number of resources, such as the Application Compatibility Cookbook, in order to aid developers in maintaining the compatibility of their applications. Microsoft Virtual PC 2007 is here! Microsoft Virtual PC 2007 is a virtualisation suite specifically designed to optimise the Windows Vista experience. It allows users to run multiple operating systems on the one machine, which offers many advantages to developers and end-users alike. The most obvious benefit of Virtual PC is that it allows developers to develop and test incompatible and legacy applications in parallel while migrating to Vista, therefore creating a smooth migration process and allowing mission critical operation to run as per normal. Virtual PC 2007 works by emulating a standard PC and its associated hardware resources, therefore creating a virtualised environment which mirrors that of a genuine PC. The new features that Microsoft Virtual PC 2007 offers include support for Intel and AMD hardware virtualization, the ability to run Windows Vista as both a host operating system and a guest operating system (however only Windows Aero Basic runs in the guest operating system), support for 64-bit host operating systems and improved performance overall. It eliminates the need for two machines as is required for the above solution and minimises the cost and time involved in setting up a new development environment. Note: At the time of writing this paper Microsoft Virtual PC Beta 1 was available. Using Microsoft Virtual PC 2007 for Development Virtual PC 2007 offers a simple solution for many application development scenarios that developers may encounter: Application Incompatibility – Virtual PC 2007 allows developers to run incompatible applications alongside Windows Vista, therefore minimising the delay in the migration to Windows Vista. Furthermore, Windows Vista itself can be run in Virtual PC 2007, creating a safe environment to carry out all testing before deployment. Problem diagnosis and testing – Virtual PC 2007 also allows users to diagnose problems and bugs which may only occur in a specific operating system or environment. Testing can also be carried out easily on different platforms without the need for multiple machines, therefore significantly reducing cost and time involved in testing and problem diagnosis. Support for end-users – Virtual PC 2007 also allows developers to duplicate scenarios/problems which end-users encounter with specific applications. Developing and Maintaining .NET Framework 2.0 Applications in Windows Vista Consider the situation where a developer has an existing .NET Framework 2.0 application that they have developed using Microsoft Visual Studio 2005. The developer’s organization upgrades to 32 bit versions of Vista and the developer finds that the application he is developing doesn’t function correctly in Windows Vista. In addition Visual Studio 2005 encounters many problems when running in Windows Vista. The developer has two options to get his application working in Windows Vista. Note: Microsoft Visual Studio 2005 without SP1 is not supported in Windows Vista. Developers need to upgrade to Microsoft Visual Studio 2005 SP1 and use workarounds for any problems they may encounter. An alternative to this is to develop in a virtualised environment using Microsoft Virtual PC 2007. Solution 1 – Use Microsoft Visual Studio 2005 SP1 (Recommended) For most developers, Visual Studio 2005 Service Pack 1 will continue to work as normal in Windows Vista. However, one may encounter some issues in certain areas. When using Visual Studio 2005 Service Pack 1 in Windows Vista, users should do the following three points for optimum functionality: 1. Be a member of the "Administrators" group on the local machine 2. Select the "Run as administrator" to run Visual Studio with elevated permissions In the Start Menu navigate to Visual Studio 2005 Right click and select “Properties” Open the “Compatibility” tab Select “Run as administrator” Click “OK” 3. Run Visual Studio 2005 in “Windows XP (Service Pack 2)” in program compatibility mode In the Start Menu navigate to Visual Studio 2005 Right click and select “Properties” Open the “Compatibility” tab Select “Run this program in compatibility mode for:” and scroll down to “Windows XP (Service Pack 2)” Click “OK” The most common problems that occur during development in Windows Vista and their respective workarounds are detailed in the following resources. Visual Studio on Windows Vista FAQ Visual Studio 2005 on Windows Vista Issue List - Running with Normal User Permissions Visual Studio 2005 on Windows Vista Issue List - Running with Elevated Administrator Permissions Example – Web Application projects may not install in Windows Vista Before loading a Web Application project in Visual Studio 2005, you will need to install Web Application Projects for Visual Studio 2005. However the installation may fail giving you an error: “The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2869”. This is because the installation package interacts with another program, in this case Visual Studio 2005 and during that process is denied permission. To alleviate this problem follow these steps: 1. Before installing “Web Application Projects” or “Web Deployment Projects” create a .bat file, enter the following text – msiexec /i <file path>\WebApplicationProjectSetup.msi – and save the file. 2. Right click the .bat file and select “Run as administrator”. Solution 2 – Use Microsoft Virtual PC 2007 For an experience identical to Windows XP, developers can also use Microsoft Virtual PC 2007 to continue developing their applications in Windows Vista. The process of developing in Virtual PC includes: 1. Installing Microsoft Virtual PC 2007 on the Windows Vista machine 2. Creating and configuring a virtual machine for the application in Virtual PC 2007 3. Installing the guest operating system (Windows XP) in the virtual machine 4. Installing Visual Studio 2005 and other applications in the guest operating system 5. Creating a build of the application being developed 6. Running the application in the host operating system (Windows Vista) and logging all the exceptions and errors which occur 7. Debugging and modifying the application in the guest operating system (Windows XP) 8. Creating another build of the application after the appropriate changes have been made 9. Installing and testing the latest build of the application in the guest operating system 10. Repeating steps 6 to 9 as needed This process is outlined in detail later in this paper. Developing and Maintaining .NET Framework 1.1 Applications in Vista Consider the situation where a developer has an existing .NET Framework 1.1 application which was developed using Visual Studio .NET 2003. The developer’s organization upgrades to 32-bit versions of Windows Vista, and the developer finds that the application that he is developing is not functioning as expected in Windows Vista. In addition, Visual Studio .NET 2003 is not supported in Windows Vista. The developer has two options to get his application working in Windows Vista. Note: Visual Studio .NET 2002 and 2003 will not be supported by Microsoft in Windows Vista. Developers can still install these, although it is not recommended, as they may experience unexpected behaviour. For example when installing Visual Studio .NET 2003, you may be prompted to install Front Page Server Extensions to run Web Projects in Visual Studio (Figure 1). Due to the changes in IIS 7.0 this is no longer an option in Windows Vista, therefore developers will not be able to open Web Projects. Figure 1 – Prompt to install Front Page Server Extensions To debug and modify .NET 1.1 applications, developers have two options. One solution is to test the application on a Windows Vista machine while debugging and modifying on a Windows XP machine. Another is to use Microsoft Virtual PC 2007 to set up a virtual environment with Windows XP and debug the application in the virtual machine. The developer can also use remote debugging to make using Virtual PC 2007 a much easier and efficient process. Solution 1 - Testing on Windows Vista while Debugging and Modifying on Windows XP Two separate machines are required for this solution. One machine needs to be running Windows Vista, while the other needs to be running Windows XP. The steps to follow in order to carry out the above procedure include: 1. Installing Windows Vista on the first machine 2. Installing Windows XP on the second machine 3. Installing the application on the Windows Vista machine 4. Creating a build of the application being developed 5. Running the application and logging all the exceptions and errors which occur 6. Loading the source code on the Windows XP machine 7. Using the information provided in the error log in step 4, to debug the application by locating the source of the error and modifying the code 8. Creating another build of the application after the appropriate modifications have been made 9. Installing and testing the latest build of the application on the Windows Vista machine 10. Repeating steps 6 to 9 as needed Solution 2 – Using Microsoft Virtual PC 2007 (Recommended) Both scenarios outlined in this paper can be overcome by utilising Microsoft Virtual PC 2007. The process of using Microsoft Virtual PC 2007 to debug applications The steps to follow when using Virtual PC 2007 to debug and modify applications include: 1. Installing Virtual PC 2007 on the Windows Vista machine 2. Creating and configuring a virtual machine for the application in Virtual PC 2007 3. Installing the guest operating system (Windows XP) in the virtual machine 4. Running the application in the host operating system and logging all the exceptions and errors which occur 5. Debugging and modifying the application in the guest operating system (Windows XP) 6. Creating a test build of the application after the appropriate changes have been made 7. Installing and testing the latest build of the application in the guest operating system 8. Repeating steps 4 to 7 as needed Installing Virtual PC 2007 The first step, as outlined above, is to install Virtual PC 2007 on the Windows XP machine. Virtual PC should be installed as a user that is part of the local Administrators group. During the installation process, confirmation of the location to which Virtual PC is installed needs to given (Figure 2). Figure 2 – Installing Virtual PC 2007 Creating and Configuring the Virtual Machine The first time Virtual PC 2007 is run, the New Virtual Machine Wizard will open. If Virtual PC has been run before, then this wizard can be accessed by opening the Virtual PC Console and clicking New. Creating a new Virtual Machine 1. Open the Virtual PC Console and click “New”. 2. When the New Virtual Machine Wizard opens, click “Next”. 3. Select the “Create a Virtual Machine” option and click “Next”. 4. Type in the name with which you would like to identify the virtual machine and click “Next”. To save the virtual machine in a different location than the specified default, click the “Browse” button and navigate to the appropriate folder. 5. Select the guest operating system that you would like to install, which in this case is Windows XP (Figure 3). Figure 3 – Selecting Windows XP as the Operating System 6. Ensure that “Using the Recommended RAM” is selected and click “Next”. To modify the RAM allocated to the virtual machine, select the “Adjusting the RAM” option and adjust the slider to the appropriate amount. 7. Select the “New virtual hard disk” option and click “Next”. 8. Type in the name with which you would like to identify the virtual machine’s hard disk and click “Next”. To save the virtual machine’s hard disk in a different location than the specified default, click the “Browse” button and navigate to the appropriate folder. 9. Verify that the options selected are correct and click “Finish”. The Virtual machine that was just created should appear in the Virtual PC Console (Figure 4). Many of the settings for the virtual machine can be configured and modified using the Settings Panel. Figure 4 – The virtual machine in the Virtual PC Console Configuring the Virtual Machine 1. In the Virtual PC Console select the Virtual Machine you would like to configure and Click “Settings”. 2. In the Settings Panel select and modify the appropriate settings (Figure 5). Figure 5 – The Settings panel Each of the virtual devices and settings can be configured by selecting them and changing the settings in the adjacent pane. For example, the amount of RAM allocated to the virtual machine can be increased by selecting Memory and moving the slider to the appropriate amount. Note: The majority of the settings can only be modified after the Virtual PC has been shut down. These settings take effect, the next time the Virtual PC starts up. Installing the Guest operating System After creating and configuring the virtual machine, the guest operating system needs to be installed. The process of installing the guest operating system (in this case Windows XP), is the same for both the virtual machine and any other physical machine. For example, if the operating system would normally be installed on the physical machine from a CD-ROM. To install the operating system on the virtual machine the following steps would be taken: 1. Insert the CD-ROM into the physical machine. 2. Start the Virtual PC from the Virtual PC Console. 3. Click “Actions” on the Virtual PC Window and Select the appropriate drive to load the CD-ROM from, for example Use Physical Drive D: (Figure 6). Figure 6 – Selecting the drive to load the CD-ROM You may need to change the Boot Order in the BIOS settings in order to boot from the CD-ROM. You can do this by pressing the Del key when the Virtual PC is starting up (Figure 7). Figure 7 – The Virtual PC’s boot screen 4. Follow the instructions on screen to complete the installation of the operating system. An ISO image can also be used to perform the installation, as Virtual PC allows you to use ISO images as if it was a physical CD-ROM. Installing Applications in the Guest operating System Once the operating system has been installed, the virtual machine can be used exactly like a physical machine. Hence, the process of installing applications mirrors that of any physical machine. For example, if the application was to be installed from a CD-ROM, then the CD-ROM would be loaded into the physical machine and accessed through the virtual machine’s virtual drive, similarly to when installing the guest operating machine. In some cases you may need to access some network resources in order to install your application. The process of connecting to the network is the same for both the virtual machine and the physical machine. You can join the network by opening up the System Properties in the virtual machine, selecting the Computer Name tab and clicking “Change…”. Licensing Information While using virtual machines, you should ensure that each operating system and application installed in the virtual machine environment is correctly licensed. In most cases, you are required to purchase a licence key for each operating system and application installed. Microsoft Windows Vista Enterprise Edition however gives users the right to use a single license key within four additional virtual machines. For other operating systems and applications please contact your software vendor. Using Remote Debugging in Microsoft Virtual PC 2007 for Development (Advanced Users) An alternative method to the process of debugging in Virtual PC explained above, is to use remote debugging in Virtual PC. Remote Debugging is the process of controlling an application by running Visual Studio, on one machine (host debugging machine), while running the application and the remote debugging monitor on another (remote debugging machine). By using Remote Debugging within Virtual PC there is no need to follow the procedure of creating test builds of the application and installing the application on the Windows Vista machine every time a modification is made. The developer can simply load the source code in the host debugging system in Virtual PC, attach it to the process in the remote debugging machine and debug the application. The steps to follow when setting up a remote debugger in Visual Studio 2005 include: 1. Configuring the remote debugging monitor (msvsmon.exe) 2. Configuring the host debugging (Windows XP in Virtual PC) machine 3. Configuring the remote debugging machine (Windows Vista) 4. Starting the remote debugging monitor on the remote debugging machine 5. Connecting to the remote debugging machine in Visual Studio by attaching to the appropriate process Note: The steps outlined below are relevant to Visual Studio 2005, however the process of remote debugging in Visual Studio .NET 2003 is very similar. Prerequisites Remote Debugging Monitor (details provided below) Both computers must be on the same domain OR Both computers must have local system accounts with the same user name and password if they are on domains with two way trust, in a workgroup or different domains Note: For computers on the same domain, if different user accounts are used on the host and remote machines, an administrator account must be used on the host debugging machine. Configuring the Remote Debugging Monitor (msvsmon.exe) on Windows Vista 1. Start the remote debugging monitor on the remote debugging machine by double clicking the executable msvsmon.exe that is appropriate to the architecture of the remote debugging machine. The executable can be found in the following locations: 32 bit machines Install path \Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86 64 bit machines Install path \Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x64 Itanium 64 machines Install path \Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\ia64 If the remote debugging machine doesn’t have Visual Studio installed, the Remote Debugger folder can simply be shared out and the remote debugging monitor can be run from the file share. 2. When running the remote debugging monitor for the first time you, will be prompted to enable the correct firewall settings. Choose the one appropriate to your situation. “Unblock remote debugging from computers on the local network (subnet)” is recommended (Figure 8). Figure 8 – Choosing the appropriate firewall settings 3. On Windows Vista after following the previous step, you may encounter the following error (Figure 9): “Could not configure the Windows firewall. Cannot add a port to the Windows Firewall exception list. Use the Control Panel to manually configure the Windows Firewall.” Figure 9 – Firewall settings error message You will need to configure the Firewall settings manually on both computers in order to allow the host debugging computer to gain access to the remote debugging computer. This process is outlined in “Configuring the Host Debugging Machine (Windows XP in Virtual PC)” and “Configuring the Remote Debugging Machine (Windows Vista)” sections below. 4. When the Remote Debugging Monitor is running, click “Tools” and then “Options”. 5. In the Options window select the “Windows Authentication Option”. Note: The No Authentication Mode can be used for native code only, however poses a security risk and therefore should only be used on slow networks if the speed of connection is more important than the security of the network. 6. Click the “Permissions” button. 7. Select the user or group that that user belongs to in the “Permissions for remote debugging” list. If the user doesn’t already exist in the list then click the “Add” button, enter the user or the group in the “Enter the object names to select” box and click “OK”. 8. Select the “Allow” checkbox in the Debug row (Figure 10). Figure 10 – Allowing the user to debug the remote machine 9. Click “OK” to close the Permissions for remote debugging dialog box. 10. Click “OK” to close the Options window. Note: Multiple instances of the remote Debugging Monitor can be run on the same computer so multiple users can debug on the same machine. Each instance is given a different server name and the correct server name must be entered when connecting to the remote debugging machine. Configuring the Host Debugging Machine (Windows XP in Virtual PC) 1. From the Start Menu click “Control Panel”. 2. Click the “Security Center” icon. 3. Click the “Windows Firewall” link. 4. In the Windows Firewall Settings window, click the “Exceptions” tab. 5. In the Exceptions Tab, click the “Add Port…” button. 6. Open the TCP port 135 by selecting a name for the port, specifying 135 as the Port Number, selecting TCP and clicking “OK” (Figure 11). Figure 11 – Opening TCP port 135 Note: It is also recommended that you change the scope of the port connection by clicking the “Change Scope…” button, selecting “My network (subnet) only” and clicking “OK”. 7. If IPSec is used over the network, you need to open the UDP ports 4500 and 500. Click the “Add Port…” button, specify 4500 as the Port Number, select UDP and click “OK”. Repeat this process for the UDP 500 port. 8. Add devenv.exe to the application security exception list by clicking “Add Program…”, clicking the “Browse” button and navigating to where the executable devenv.exe is located. It can typically be found at: Install Path\Program Files\Microsoft Visual Studio 8 Common7\IDE. 9. Click “OK” to close the Select a Program window. 10. Click “OK” to close the Windows Firewall window. Configuring the Remote Debugging Machine (Windows Vista) 1. From the Start Menu click “Control Panel”. 2. Click the “Security” button. 3. Click the “Windows Firewall” button. 4. Click the “Change Settings” link. 5. In the Windows Firewall Settings window, click the “Exceptions” tab. 6. In the Exceptions tab, click the “Add Port…” button. 7. Open the TCP port 135 by selecting a name for the port, specifying 135 as the Port Number, selecting TCP and clicking “OK”. Note: It is also recommended that you change the scope of the port connection by clicking the “Change Scope…” button, selecting “My network (subnet) only” and clicking “OK”. 8. If IPSec is used over the network, you need to open the UDP ports 4500 and 500. Click the “Add Port…” button, specify 4500 as the Port Number, select UDP and click “OK”. Repeat this process for the UDP 500 port. 9. In the Programs and Services list, select “File and Print Sharing” if it isn’t already selected. 10. You also need to add msvsmon.exe to the exceptions list. Do this by clicking the “Add a Program…” button, navigating to the executable “msvsmon.exe”, clicking “Open” and clicking “OK” (Figure 12). Figure 12 – Adding the Remote Debugging Monitor to the Exceptions list 11. Click OK to close the Windows Firewall window. Starting the Remote Debugging Monitor on the Remote Debugging Machine (Windows Vista) Start the remote debugging monitor by navigating to the executable msvsmon.exe. Connecting to the Remote Machine in Visual Studio by Attaching to the Appropriate Process 1. Open Visual Studio on the host debugging machine (Windows XP in Virtual PC). 2. Place breakpoints in the code where you would like the debugger to stop. 3. Go to “Tools” and click “Attach to Process”. 4. In the new window enter the computer’s name to which you are connecting in the “Qualifier” box in the format Domain\Username@ComputerName. For example VISTA\IshitaPrasad@DEV1 5. In the Available Processes list select the process associated with the application you are trying to debug (Figure 13). Figure 13 – Attaching to the process Figure 14 – Host debugging machine is connected to the remote debugging machine The host debugging computer and the remote debugging computer are now both connected and the application can now be debugged. Best Practices for Building Your VPC Environment and Testing and Deploying Applications Turn on undo disks – Undo Disks is an innovative feature of Virtual PC’s which allows users to rollback the Virtual PC to the last time changes were committed to the Virtual PC’s hard disk. This is achieved by saving all the changes made to the Virtual PC separately and only committing those changes during shutdown. This allows the user to select the option of not committing the changes at all. Undo Disks are particularly useful when testing in volatile situations or when critical changes are being applied, as it creates a fail-safe environment where all changes can simply be reversed. However in some cases such as keeping undo disks that haven’t been committed to the virtual hard disk can create a large amount of disk-related overhead and therefore it is recommended that developers store the undo disks and a separate physical disk to the virtual hard disk. Turn on Undo Disks, by following these steps: 1. In the Virtual PC Console, select the Virtual Machine you would like to configure and Click “Settings”. 2. In the Setting Panel, select “Undo Disks” and select “Enable Undo Disks” (Figure 15). Figure 15 – Turning on Undo Disks Optimise memory usage – Virtual PC’s are heavily dependant on the memory resources available on the host machine running them. Therefore, to optimise memory usage, the memory footprint should be set to twothirds of that available on the machine on which it is run, if it is the only Virtual PC being run on the host machine. Furthermore, all non-essential services and applications running on the host machine should be shut down. Use Virtual PC to test betas – Betas are perfect candidates for running on Virtual PCs, as their fundamental function is to provide a baseline application that can be tested for bugs and possible improvements. Betas can also be unpredictable and can cause instability if they encounter a problem. Virtual PCs can be utilised for this scenario, as they offer a secure and protected environment for carrying out testing on betas without affecting the host machine. Store the virtual hard disk on a separate physical disk to the operating system – by storing the virtual hard disk on a separate physical disk or hardware that offers better performance and fast access, you can significantly improve the performance of the Virtual PC, as it will utilise the resources of the physical disk while freeing up resources for the host operating system. For optimum performance, SCSI hard disks, redundant array of independent disks (RAID) or a SAN should be used to store the virtual hard disks. Protect your virtual environment – the virtual environment mirrors any physical operating system and is therefore vulnerable to the same viruses and malware that affects any other operating system. Hence it is necessary to protect the Virtual PC environment in the same fashion as the host operating system. This means installing anti-virus protection on each virtual machine, enabling a firewall to block unwanted incoming and outgoing traffic and installing the latest security patches and updates to ensure that the virtual machine is protected against the latest security threats. Backup the virtual machine – the virtual machine acts like any data storage device and the associated virtual machine files should be backed up to save all of the data and configuration settings of that particular virtual machine. The easiest method for backing up the virtual machine is to simply backup the virtual hard disk onto a secondary storage device. The process of restoring the image is just as simple. Correct shut down procedure – before shutting down the host operating system, it is vital that the virtual machine be shut down first. This is to ensure that no data has been lost. Similarly when suspending the host operating system, the virtual machine must be suspended first to avoid data loss. Installing Virtual Machine Additions - Virtual Machine Additions are a set of features that improve the integration of the host and guest operating systems. It also improves the performance and manageability of the guest operating system. Some of the special features included are mouse pointer integration, time synchronization and overall improvement in the performance of the guest operating system. Install the virtual machine additions by following these steps (Figure 16): 1. Start the Virtual machine by selecting the appropriate virtual machine in the virtual machine console and clicking “Start”. 2. When the virtual machine window opens, click “File” and select “Install virtual machine additions”. 3. You will be prompted for confirmation, click “yes”. Figure 16 – Installing Virtual Machine Additions Configure performance settings for the virtual machine – Performance improvements can also be experienced if the following settings are applied (Figure 17): 1. In the Virtual PC Console, click “File” and then “Options”. 2. In the Options window, click “Performance”. 3. Select both “All running virtual machines get equal CPU time” in the right pane and “Run Virtual PC at maximum speed” and click “OK”. Figure 17 – Configuring Performance Settings To enable hardware acceleration the following steps should be followed (Figure 18): 1. Click “Start”, then “Run”, type desk.cpl and click “OK”. 2. Click “Advanced Settings”. 3. Open the “Troubleshoot” tab. 4. Click “Change Settings” and move the hardware acceleration slider to full. Figure 18 – Enabling Hardware Acceleration Defragment your virtual machine – virtual machines should be defragmented regularly for optimum performance. This includes both the physical drive on which the Virtual hard drive is located as well as the virtual drives within the Virtual PC. By doing this you can experience a significant improvement in the speed of the Virtual PC. The built in Windows defragging tool or any other 3rd party tool can be utilised. Exclude your virtual machine from anti-virus scans – exclude your virtual machine files from being scanned by your host anti-virus software. This includes files such as .vmc, .vhd and .vud. Scanning these files slows down the host operating system and is unnecessary as the anti-virus software installed in your Virtual PC performs the same task. Summary Microsoft Windows Vista and its new security features, although providing a much more secure operating system environment for users, may hinder many applications from functioning as normal within the host operating system. As well as this, the security enhancements have meant that Visual Studio .NET 2003 will not be supported in Windows Vista and Visual Studio 2005 SP1 may encounter problems. Virtual PC 2007 offers a simple, economical and easy-touse solution to overcome these limitations in Windows Vista. By virtualizing another operating system on the one computer, it eradicates the need for new hardware and allows users to run applications in the host environment while developing in the guest environment. To continue developing .NET 2.0 applications, developers need to upgrade to Visual Studio 2005 SP1 (recommended) and use workarounds for any issues they encounter or use Microsoft Virtual PC 2007 to set up a virtualised environment with Windows XP as the host operating system. To continue developing .NET 1.1 applications, developers need to set up a virtual environment in Microsoft Virtual PC 2007 (recommended) or test their application on a Windows Vista machine and debug on a Windows XP machine. Developers will also find that using remote debugging between the host operating system (Windows Vista) and the guest operating system in Virtual PC (Windows XP) beneficial, as it eliminates the time and effort required to create tests builds when testing applications on Windows Vista. More Information For more information on Windows Vista, visit: Windows Vista Home Page For more information on Application Compatibility in Windows Vista, visit: The Windows Vista Developer Story: Application Compatibility Cookbook For more information Windows Application Compatibility Resources, visit: Windows Application Compatibility