• No results found

Microsoft Virtual Labs. Windows Embedded CE 6.0 Writing C# Managed Applications

N/A
N/A
Protected

Academic year: 2021

Share "Microsoft Virtual Labs. Windows Embedded CE 6.0 Writing C# Managed Applications"

Copied!
31
0
0

Loading.... (view fulltext now)

Full text

(1)

Windows Embedded CE 6.0

Writing C# Managed Applications

(2)
(3)

Windows Embedded CE 6.0 Writing C#

Managed Applications

Objectives

After completing this lab, you will be better able to: Create a Platform Image

Customize and build the OS Design

Boot the O/S Image with Networking

Write and Run a C# Managed Application

Estimated Time to

Complete This Lab

60 Minutes

(4)

interface based and headless applications.

Tasks Detailed Steps

1. Create a new OS

Design

a. Start Visual Studio 2005 with Platform Builder either using the desktop shortcut,

or…

b. Start | All Programs | Microsoft Visual Studio 2005 | Microsoft Visual Studio 2005 (there may also be a shortcut on the desktop)

c. Launch the Visual Studio 2005 New Project dialog.

• Select File | New… | Project…

d. Select the Platform Builder project type.

e. Choose the OS Design template

f. Enter a name for your project, or go with the default name

g. Click OK

Note: The initial Dialog that is displayed below outlines the process of creating an OS Design. There are a number of steps involved and you will step through the wizard and make selections as appropriate.

(5)

Tasks Detailed Steps

h. In the Welcome to the Windows Embedded CE 6.0 OS Design Wizard click

Next.

Note: We will build an operating system for the Microsoft Device Emulator. The Microsoft Device Emulator version 2.0 is a desktop application that emulates the behavior of a Windows Embedded CE 6.0 or Windows Mobile-based hardware platform. Using the Device Emulator, you can run, test, and debug a run-time image without the need for a physical device.

Note: You could select more than one BSP (Board Support Package). For example, it may be useful to select the Device Emulator and a hardware reference platform; the emulation environment can be used by your internal/external application developers to build applications for your device while hardware is still being developed.

(6)

i. Select Device Emulator:ARMV4I

j. Click Next

Note: You are now given a number of Design Templates to choose from as the starting point for this project. If none of the options match your needs you can simply select Custom Device’ and build the image based on the components you select from the catalog.

For the purposes of this tutorial you will be using the PDA Device template.

(7)

Tasks Detailed Steps

l. Click Next

Note: The Wizard now gives you the option of choosing a variant of the Design Template. For this tutorial you will be using the Mobile Handheld variant.

m.Select Mobile Handheld from the list of Design Template Variants

n. Click Next

Note: There are a number of options which can be selected for each of the sample platforms, the OS Design Wizard will only show options that are relevant to the platform you are building. For example, it would not make sense to include Internet Explorer or WordPad in a headless device such as a Residential Gateway. The Mobile Handheld device can include applications such as Internet Explorer, WordPad, and Windows Messenger and other optional components you might want to add from the catalog of components that ship with CE 6.0.

Note: In this case we don’t need the .NET Compact Framework (we will allow Visual Studio 2005 to download the Compact Framework files to the running CE 6.0 operating system image – for a production device you would of course include the .NET Compact Framework 2.0 component and your managed application in the operating system image). De-select this item.

(8)

o. De-select the .NET Compact Framework 2.0

p. Click Next

Note: Next comes networking and communications, you can see that Windows CE provides support for Personal, local, and wide area networking through technologies such as Bluetooth, IrDA, Wired and Wireless networking, and VPN.

In our case lets deselect IPV6, we could add this component back into the operating system later using the catalog.

(9)

Tasks Detailed Steps

r. Click Next

Note: We’re done! – The wizard is complete. You’ve configured the OS Design and can now further customize it by adding and/or removing components from the Catalog.

s. Click Finish

Note: The Wizard will now prompt you with any security warnings or other

notifications related to the components you selected. Acknowledge these notifications (note that you could search the catalog for the OBEX Server component and remove this from your operating system design, or read the documentation links provided on the OBEX Warning dialog to ensure that you understand the security implications of including this component).

(10)

t. Click Acknowledge

Note: At this point you have an OS Design containing all of the OS components which have been selected from the Wizard. In the next section we will further customize the OS Design using the Catalog.

(11)

Exercise 2

Customize and build the OS Design

Tasks Detailed Steps

1. Using the Catalog Note: You will now make changes to the items included in your OS Design using the

Catalog View.

First, ensure that the Catalog View is visible.

a. Select the View menu

b. Choose Other Windows | Catalog Items View

Note: You are going to be writing a C# managed application and deploying this to the CE 6.0 ARM Emulator (Device Emulator 2.0), there are a number of components that you need to add from the catalog before building the operating system image, these are:

IPConfig – you will need to know the IP address of your emulator image

WCELoad – you will want Visual Studio to download the Compact Framework (as a .CAB file) and expand this on your device, the WCELOAD component is the CAB File installer/uninstaller.

Web Server – The Web Server (HTTPD) can be used to make sure we can browse

to the IP address of the running operating system image (you could also ping the device emulator from the desktop)

Compact Framework Dependencies for UI based Devices – Even though you have

not added the Compact Framework to your operating system image you still need to include the dependencies for the Compact Framework, this ensures that all of the operating system technologies needed to support the Compact Framework are included in your operating system

CoreCon ARMV4I component – This is a custom component (the component

doesn’t ship with Visual Studio 2005 or CE 6.0) that exposes the CoreCon device side applications (Conmanclient2 and Cmaccept) – these applications are needed on your device for Visual Studio to deploy applications and CAB files to your device (assuming that you are connecting to your device using Ethernet rather than ActiveSync) – more on this later in the lab.

Note: There are a couple of ways you can locate features in the catalog, you can either browse the catalog and locate the feature you’re interested in manually (for example you may know that the .NET Compact Framework 2.0 component lives in the Core OS | CEBASE | Applications and Services Development node of the catalog), alternatively you can use the catalog search feature to locate the component you are interested in.

You want to ensure that IpConfig is included in the run-time image that you build. Search for “ipconfig” to locate the appropriate catalog item.

(12)

c. Type ipconfig in the catalog items search box d. Hit Enter to search

e. Check the box next to the Network Utilities (IpConfig, Ping, Route) item to

include it in your OS Design

Note: The catalog search feature can be used to either search on names or part of names (for example searching on “Soli” would locate the Solitaire component in the catalog or to search on a components SYSGEN value, for example searching for SYSGEN_HTTPD would locate the HTTPD Web Server which you will be adding to the operating system shortly.

f. Type SYSGEN_HTTPD in the catalog items search box

g. Hit Enter to search

h. Check the box next to the Web Server (HTTPD) item to include it in your OS

Design

Note: Note that adding the HTTPD Web Server to your operating system will display a Security Warning (see below) – you have two choices at this point, you can either click Acknowledge to add the HTTPD Web Server to your operating system image, or hit Cancel to not add the component to the operating system image – notice that the Security Warning dialog provides best practice information on how to use this feature securely.

(13)

Tasks Detailed Steps

i. Type wceload in the catalog items search box

j. Hit Enter to search

Note: When you searched for the SYSGEN_WCELOAD component you were viewing the server node of the catalog – the SYSGEN_WCELOAD (Cab file

installer/uninstaller) lives in the Applications – End User node of the catlog (the first node of the catalog) – the catalog search will start from your current location and search to the end of the catalog – since the component is at the top of the catalog you will get the following warning message.

k. Click Yes to continue the search from the top of the catalog.

l. Check the box next to the CAB File Installer/Uninstalleritem to include it in your OS Design

(14)

m.Type SYSGEN_DOTNETV2_SUPPORT in the catalog items search box n. Hit Enter to search

o. Check the box next to the OS Dependencies for .NET Compact Framework 2.0

item to include it in your OS Design

Note: You will probably have noticed that the catalog items have either squares or circles to represent operating system technologies (see below) – the items that have a circle show that you can choose just one of the options the .NET Compact Framework 2.0 UI and Headless components are a good example of this. Items that have a square are stand-alone components and therefore don’t conflict with other components.

Note: You’ve now added all of the components needed to build a CE 6.0 operating system that can run .NET Compact Framework applications.

Note: The next step is to add support for developing/downloading/debugging managed applications against the operating system you’ve configured.

Unlike Windows Mobile devices (Pocket PC or Smartphone) which are typically connected to a developers PC using USB and ActiveSync many CE 6.0 embedded devices will be connected over Ethernet – in this case we need to run two applications

(15)

Tasks Detailed Steps

on the device to prepare for application development and debugging from Visual Studio 2005 – these are known as ConManClient2 and CmAccept and ship with Visual Studio 2005 (note that to develop applications against a CE 6.0 device you need Visual Studio 2005 SP1 which provides an update to the ConMan components) – the ConMan files are typically installed to the following folder - C:\Program

Files\Common Files\Microsoft Shared\CoreCon\1.0\target\wce400\<processor type>

Note: To make it easy to add the ARMV4I ConMan components to your operating system design we’ve created a Third Party component called ConMan_ARMV4I Files Component– this component can be found in the

C:\WINCE600\PUBLIC\ConMan_ARMV4I folder on your Virtual Lab PC – this is a simple component that doesn’t have any source code and uses the components BIB file and postlink.bat files to copy the ConMan files into the build release folder for your project and then include the ConMan files into your operating system image. Note that you wouldn’t typically ship the ConMan files with your operating system image. p. Scroll to the end of the catalog

q. Expand the Third Party catalog node

r. Check the box next to the ConMan_ARMV4I Files Componentitem to include it

in your OS Design

Note: The Catalog is an important tool for configuring your OS Design. If you choose to explore this view further, you will find advanced features for the analysis of

dependencies between the various items.

2. Configure the OS

Build Options

Note: The default build option is to build a Debug operating system image, for the purposes of this lab we’re not interested in debugging the operating system, but are more interested in writing, deploying, and debugging C# applications from Visual Studio 2005 – you can change the build option from debug to release – the operating system image will boot faster as a release build since the amount of debugging information will be reduced.

(16)

d. Expand Configuration Properties

e. Select the Build Options node

f. Click OK to close the Property Pages dialog

3. Setting operating system deployment options

Note: For this lab you will be deploying your CE 6.0 operating system to the ARM based Device Emulator, which has a number of configuration options, this includes screen width/height, color depth, amount of available ARM, network configuration, and supported peripherals (serial ports, battery, and others).

Note: This lab has been configured to run inside the Virtual Lab environment, in order to allow inbound network connections to the ARM Emulator running inside the Virtual Lab we’ve added support for Virtual Machine Networking Services and the Microsoft Loopback adapter – in this configuration the Emulator boots and gets an auto-IP address which can then be pinged from the Virtual Machine desktop or from Visual Studio 2005.

You will now setup the Emulator networking settings.

a. Select Target | Connectivity Options

Note: There are a number of options that can be set on the Target Device Connectivity Dialog – this includes the download/debug transport which could be Ethernet, Serial, Device Emulator (DMA), Image Update, USB or None – To connect to the ARM Emulator we will be using the Device Emulator (DMA) option.

(17)

Tasks Detailed Steps

Confirm you have Device Emulator (DMA) for Transport Confirm you have KdStub for Debugger

Note: You will now change some of the Emulator settings, specifically configuring the network settings.

b. Click the Download Settings button (highlighted below).

c. Clicking Settings displays the following dialog – You will notice a number of tabs General, Display (for screen size/color depth), Network (to setup your network options), and Peripherals for working with serial ports etc…

(18)

d. Click the Network tab on the Emulator Properties dialog.

e. Click NE2000 PCMCIA network adapter and bind to: to enable the network

adapter.

Note: Note that the default option is to bind to your connected network card.

f. Drop the Network adapter list and select Microsoft Loopback Adapter – Virtual

Machine Network Services Driver

g. Click OK

h. Click Apply & then click Close

4. Build the OS Design Note: At this point, you would be all ready to build your OS Design. You now have

two options, either build the operating system (this could take more than 10 minutes to complete) or move onto the next step in the lab using an pre-built operating system image.

To build the operating system:

a. Select Build | Build Solution – note that this could take more than 10 minutes to complete.

(19)

Tasks Detailed Steps Project/Solution…

c. Browse for and open the Solution:

C:\Wince600\OSDesigns\AppDev\AppDev.sln d. Select Yes to save changes if you wish.

Note: The prebuilt Solution you have opened contains everything you have done so far:

A Mobile Handheld Template

Ipconfig

Httpd web server ConMan files

Wceload (Cab File installer/uninstaller) .NET Compact Framework dependencies

(20)

should switch from the Command Window to the Output view.

b. Click on the Output tab at the bottom of the Visual Studio UI to show the debug output from booting the operating system – this will also be useful when you need to capture the IP address of the device.

2. Obtaining the

Emulator IP Address

Note: In order to deploy a managed application from Visual Studio 2005 to the emulator device you need to determine the IP address of the emulator operating system image – you have included the IPConfig utility in the operating system image, this can be used to determine the IP address of the running operating system image.

Note: Note that it may take a few seconds before the network adapter has a valid IP address – you will notice that the networking icon on the task bar will initially show a network icon with a red cross through it , this shows that the network adapter is up and running but doesn’t have a valid IP address (see full task bar image below).

Note: Once the emulator has a valid IP address the networking icon will change to show a valid IP address/connection (the red cross will be removed from the networking icon).

Note: You can use Target Control to obtain the devices IP address.

a. In Visual Studio: Open Target | Target Control

(21)

Tasks Detailed Steps

command used to start/launch ipconfig application on the device – you could also use the Target | Run menu option) – the ‘/d’ switch is used to send the output from ipconfig to the Visual Studio/Platform Builder debug output window.

Note: The Debug Output window in Visual Studio/Platform Builder will display the IP address of the running emulator image.

Note: In this case the Emulator has an IP address of 169.254.112.165 (and a Subnet mask of 255.255.0.0) – You will need to save this IP address to configure Visual Studio for application deployment.

c. Make a note of the IP address you obtained from running the ipconfig utility – you could highlight the IP address and copy to the clipboard (right click/copy) or simply write the IP address down for later use.

(22)

d. Select Project type: Visual C# | Smart Device | Windows CE 5.0

Note: Note that you are selecting a Windows CE 5.0 project type and deploying the application to a CE 6.0 device.

e. Change the Project name to something appropriate or leave the default name

f. Click OK to create the Smart Device application.

Note: By default the C# application form is created at 640x480 pixels, the emulator image you have created/booted is running at 320x240, we need to adjust the form size. g. Right click on the form within Visual Studio

h. Select Properties – this will display the forms properties in the bottom right of the Visual Studio UI.

(23)

Tasks Detailed Steps

i. Scroll the Properties window to locate the Size item j. Set the form size to 320x240 (see below)

Note: The Visual Studio application wizard automatically adds a mainMenu to the application, this appears to be invisible on the form, but if you add controls close to the top left of the form then your controls would be overwritten by the mainMenu. See the image below that shows where the mainMenu would be displayed.

(24)

Note: You are now ready to populate the form by adding controls from the Toolbox. m.Hover your mouse over the toolbox (left side of the screen) – this will display the

Toolbox.

n. Click (and hold) a Button control and drag onto your form

(25)

Tasks Detailed Steps

p. [Optional] – feel free to set the button/textBox controls positions and size on the form.

q. [Optional] – you can also use the properties panel (bottom right of Visual Studio 2005) to set the name and default text of the Button and textBox.

Note: In the example below the Button and textBox text have been set to Tahoma 18pt, and the Button text has been set to Click Me!

Note: Now you are ready to add code behind the button.

r. Double click on the Button you added to the form – this will take you into a Code View within Visual Studio 2005 (see below).

Note: Visual Studio has created a button_click handler for your button and has opened the code editor at the right place for you to add your code.

s. Add the following code to the button_click handler – textBox1.Text=”Cool

Tools!”;

Note: Perhaps it would be interesting to debug the managed application once deployed to the CE 6.0 ARM emulator.

(26)

emulator.

Note: You are now ready to build your application – the final step is to configure the connection between Visual Studio 2005 and your running target device.

2. Configuring VS 2005

connection to CE 6.0 Device

Note: You’ve already captured the IP address for your running CE 6.0 operating system image, in this case you are using the ARM Device Emulator as your target. Visual Studio 2005 needs to know the IP address of the target you are going to deploy to – this would be different if we had an ActiveSync connection between the desktop and the embedded device.

a. In Visual Studio (the instance used to develop the C# Smart Device application), select Tools | Options

b. Scroll the Tree View on the Options Dialog to locate and expand the Device Tools

| Devices node.

c. Select the Properties button on the Options Dialog.

(27)

Tasks Detailed Steps

e. Select Use specific IP address: on the Configure TCP/IP dialog

f. Enter the IP Address you saved earlier in this lab (note that the IP address displayed in the dialog below may not match the IP address you saved earlier)

g. Click OK to close the Configure TCP/IP Transport dialog

h. Click OK to close the Windows CE 5.0 Device Properties Dialog

i. Click OK to close the Options Dialog

Note: Visual Studio is now ready to connect and deploy your managed application, however, the target device is not yet ready to accept the application from Visual

(28)

Note: You can use Target Control to run the two applications.

b. In Visual Studio: Open Target | Target Control

c. Type: s conmanclient2 (this will start the ConManClient2 application)

d. Type: s cmaccept (this will start the cmaccept application)

Note: You can verify that the two applications are running using a command within the Target Control Window.

e. Type: gi proc (this will display a list of running processes in the Target Control window)

Note: You can see that there are 12 processes running on the ARM Device Emulator, this includes five instances of udevice.exe – the user mode device driver manager, and also included in the list are ConManClient2.exe and Cmaccept.exe.

f. Switch to the Application Development instance of Visual Studio 2005

g. Select Debug | Start Debugging

Note: You will be prompted for the device type you want to deploy to.

h. Select Windows CE 5.0 Device

(29)

Tasks Detailed Steps

Note: Visual Studio will now make the connection to the ARM based Device Emulator using the IP address we stored earlier. Once the connection is made Visual Studio will download the ARMV4I .NET Compact Framework CAB file and install the Compact Framework on the device – once the Compact Framework is deployed the application will be deployed and started on the device, this may take a couple of minutes to complete.

Note: Once the application is deployed and started the emulator will look like the image below.

(30)

k. Press F5 to allow the application to run.

(31)

Summary

You have now completed all the steps in this guide. Here’s what we have covered:

• Created an OS Design

• Customized the OS Design by components needed to support Visual Studio application development

• Built an OS image

• Downloaded an operating system to the ARM Device Emulator

• Used Target Control to launch applications on the device

• Configured Visual Studio and Platform Builder to deploy applications to a running emulator image

References

Related documents

BIGO  (Fig.  3)  measures  sediment  water  interface  fluxes  in  benthic  chambers.  It  retrieves  water  samples  from  the  enclosed  chamber  water 

Add 100 ml of 1X TEA buffer (dilute 10X TEA buffer to make 1X – 10ml of TEA to 90 ml of distilled water in graduated cylinder.) Place agarose and buffer in microwave and heat

After documenting the growth experience of developing countries over the past 25 years and discussing the importance of research that dissects the effects of national policies

The Modified Principal Component Analysis technique shall take care of issues such as problem arising from the reconstruction of the face images using their corresponding

If one seeks to assess the equilibrium ex- change rate of any given economy, a systematic analysis using alternative economic and econometric specifications must be performed

Berdasarkan hasil penelitian yang dilakukan, maka dapat disimpulkan bahwa kondisi maksimum dari fermentasi pati sorgum ini adalah pada variabel penambahan inokulum

[r]

Only the upper surfaces of the tips are sharpened, focusing the debonding force at the Radiance Plus Debonding Pliers #001-343E. These pliers are designed to debond by placing