How to: Work with Emulators and Browsers
ASP.NET mobile controls enable you to develop applications for a wide variety of mobile devices. The manufacturers of most mobile devices provide emulators that simulate the operation of their hardware and browsers. Emulator software enables you to view your ASP.NET mobile Web pages as they might appear on the manufacturers' hardware devices, and to experience the interface for your Web site as users do. For example, after you see how a user must navigate through your site on a specific device, you might want to modify the interface using a DeviceSpecific template for that device.
Developing and testing with emulators enables you to test your mobile Web application more easily on a variety of devices before you deploy it.
There are two approaches to viewing your mobile Web pages on device emulators:
Install and use device emulators provided by manufacturers.
Use the emulators installed with some editions of Visual Studio. To use this option, you must have an edition of Visual Studio containing Device Emulator Manager, and you must have installed the ActiveSync application, which you can download from the tools page on the Windows Mobile Developer Center.
Adding an Emulator to Visual Studio
You can add an emulator to the list of browsers available in Visual Studio.
To add a device manufacturer's emulator to the list of available browsers
Compile your application.
Install the mobile device emulator on your development computer. See the emulator's documentation for instructions.
In the File menu, click Browse With.
Visual Studio displays the Browse With dialog box.
Click Add.
Visual Studio displays the Add Program dialog box.
In the Program name box, enter the name of the emulator's executable program file.
If the emulator accepts command line arguments, enter them in the Program name field. For example, enter %startpage to specify where the application's start page should be substituted in the command line.
In the Friendly name box, enter the name of the browser as you want it to appear in Visual Studio.
Click OK.
If you want the emulator to be the default browser, click Set as Default.
Click Close.
Removing an Emulator
If you no longer need an emulator, you can remove it from Visual Studio.
To remove an emulator from the browser list
In Solution Explorer, right-click the name of any .aspx file.
In the shortcut menu, click Browse With.
The designer displays the Browse With dialog box.
Select an emulator from the browser list.
Click Remove.
Visual Studio removes the emulator name from the browser list.
Hinweis
You cannot remove a browser designated as the default browser.
Testing Pages with Device Emulator Manager
All editions of Visual Studio include support for mobile Web pages. If your edition of Visual Studio also includes support for mobile device applications (such as for the Pocket PC), you have Device Emulator Manager installed, which includes several emulators. However, the emulators available with Device Emulator Manager were not originally intended for testing mobile Web pages. To use Device Emulator Manager to test your mobile Web pages, you can install ActiveSync, which is available for download from the tools page on the Windows Mobile Developer Center.
To view your Web site with an emulator using Device Emulator Manager
Compile your application.
In the Tools menu, click Device Emulator Manager.
Hinweis
If the DeviceEmulator Manager command is not available, you do not have the Compact Framework installed.
Select a device emulator.
In the Actions menu, click Connect.
The emulator appears. Move the emulator so you can see Device Emulator Manager, and wait for it to indicate that the selected device is connected.
In Device Emulator Manager, right-click the connected device emulator in the list and in the shortcut menu, click Cradle.
ActiveSync starts.
In the Set Up a Partnership dialog box, select Guest partnership and click Next.
When ActiveSync indicates the device is connected, close ActiveSync. (It will continue running in the background.)
In the emulator, navigate to your Web site.
Hinweis
An emulator might not be able to use the localhost URL to access your Web site project. If not, you can view the Web site using the intranet URL.
Debugging Web Pages in the Emulator
If Visual Studio cannot launch an emulator when debugging a Web site, you can debug your application by attaching to the ASP.NET worker process.
To debug your Web site application by attaching to the worker process
Set a breakpoint in the code you want to debug.
Compile your application.
On the Tools menu, select Attach to Process.
In the Available Processes list, select the Web site worker process (w3wp.exe or aspnet_wp.exe).
Click Attach.
The Visual Studio debugger starts.
In the emulator or browser, navigate to your Web site project.
The debugger stops at the first breakpoint.
For more information about using an emulator, see the manufacturer's emulator documentation.
See Also
Concepts
ASP.NET Browser Registration Tool (Aspnet_regbrowsers.exe)