Archive for May, 2008

Fun with Anonymous Delegates

Friday, May 23rd, 2008

I wrote some code today that made me really appreciate the new language feature in C#: anonymous delegates. I decided to turn it into a sample application that opens a web request to www.google.com and downloads it when you push a button… asynchronously (that means the UI does not hang while the application is downloading). Prior to C# 2.0, doing a web request and download the content asynchronously was several hundred lines of sloppy spaghetti code: you need to implement callbacks, cleanup, error handling, state maintenance, etc. A lot of developers, myself included, would “cheat” and wrap synchronous calls in a thread to fake asynchronous requests (this is not ideal for performance).

The beauty of anonymous delegates is that the compiler’s syntactic sugar handles a lot of the aforementioned for the developer very elegantly in the background. 

Here’s what a fully asynchronous download looks like now, with error handling and cleanup and all (5 anonymous delegates in total): Anonymous Methods Source

 

Koushik Dutta

Software Engineer

Windows Mobile Device Emulator – Installment 2: Configuration of the NE2000 Adapter

Thursday, May 22nd, 2008

Here is the follow-up installment #2 on device emulator configuration.  You may want to read installment #1 first.

I often need to test our code across various versions and SKUs of Windows Mobile.  For instance, I need to test one feature across WM 5.0 Smartphone, WM 5.0 Pocket PC Phone Edition, WM 6.0 Standard, WM 6.0 Professional and, of course, the newer WM 6.1 SKUs.

When testing, you often want to use a hard/cold booted device for the most reproducible results.  Cold booting and then reconfiguring a bunch of devices is super time consuming.  Even if using the device emulator, configuration can be time consuming.

Another important issue is network availability.  Much of my testing requires a network connection for client/server applications.  I used to connect my emulators using Desktop Passthrough via Desktop ActiveSync or Windows Mobile Device Center on Vista.  This setup invariably led to the following problems:

  1. Time spent in setup of the work/internet connection manager settings every time I reconnected
  2. ActiveSync automatically sets your HTTP proxy which is sometimes not desirable. Unfortunately, the method used by activesync to gather the proxy and proxy port from the desktop can lead to errors. For instance, our outbound proxy operates on port 8080. But, activesync configures the device to use port 80 which then causes “work” connections to internet web sites to fail.
  3. You can only connect one emulator at a time to activesync. If you want to test across multiple emulators simultaneously, you cannot use ActiveSync.
  4. ActiveSync Desktop passthrough only supports http/https traffic. If you want to use other ports/apps, it won’t work. For instance, I’ve been testing an ICMP ping application and cannot use it through desktop activesync.

These issues can be solved by utilizing the built-in NE2000 NDIS network adapter that comes with the device emulator. Here is a set of steps that I use for setup.  After you finish setup, you can save the device emulator state and when attempting a new test case, you simply close and re-open the emulator for full cold boot with configuration intact.

Here is how I go about configuring the emulator to meet my testing requirements.

First, if you’ve ever saved state on the device emulator image before, right-click the image in the Device Emulator Manager and choose “clear save state”.  This provides a true default, factory-reset image as your starting point.  There is an option in the emulator’s file menu for cold reset, but it does not take the device back to a truly “clean” state.

Next, in the Device Emulator window, open the File menu and select “configure”. 

In the “General” tab, you can configure a “Shared Folder”.  I like to share a folder located on my desktop to the device emulator by configuring the “shared folder” setting.  Once configured, you can open desktop files in the emulator by browsing the “storage card” volume in file explorer on the device emulator.  If using multiple emulators, you can set them to all use the same shared folder.  This allows you to copy files into the desktop folder and then open the identical file on all emulators.  For instance, you could copy CAB Provisioning Files (.CPF) to the desktop shared folder and execute them from the device emulator’s file explorer to easily configure the device.

In the “Network” tab, you can setup your emulated NE2000 adapter.  Just select the checkbox for “Enable NE2000 PCMCIA network adapter and bind to:” and select “Connected Network Card”.  The NE2000 will bind to the first network adapter it finds on the desktop computer after you click OK on the “Emulator Properties” checkbox.

You may find that you still can’t connect to known servers using the device emulator’s Mobile IE browser.  That is likely due to work/internet settings.  Here is what you do:

  1. Open settings
  2. Open connections:
    • On PPC, click the “Connections”
    • On Smartphone, just open the “Connections” setting menu item.
  3. On PPC emulators, route “Network Cards” to the correct network: “work” or “internet”. If your desktop is connected to a private/work network with a firewall that requires proxying to the internet, set “Network Cards” to point to “Work”. NOTE: Smartphones are hardcoded such that the NE2000 adapter always routes to “work”. You can see this by by opening the “menu” and selecting “Adanced” on the “Connections” menu. You won’t be able to change it to route to “internet”. If you don’t configure a proxy setting, it won’t make a difference.
  4. If you selected “work”, then you likely need to configure a proxy. Open “Connections” again as you did in step 2 above.
    • On PPC, open “Connections” and click the hyperlink for “Edit my proxy server”
    • On Smartphone, open “Proxy” and click “Add” off of the Proxy “menu”
  5. Test your connection by opening both an internet web site and a private/work network website in Mobile IE. You may need to change your proxy and/or network card routing configurations.

At this point, you may want to configure some of the following:

  • Root and intermediate certificates
  • Mobile IE Favorites
  • Application installations

After you’ve finished creating your base image configuration, click the “File” menu in the device emulator windows and select “Save State and Exit”.  After the save process is finished, reopen the same emulator image and you’ll find that its configured and ready for your first test case!  After you’ve completed a test case, close the emulator, but do NOT save the emulator image or it will overwrite your carefully created image.  Re-open the image and you’ll find that you are right back to your base image configuration and ready for your next test case.

If you are using multiple device emulator instances to test a client/server application, you can have them all open and connected at once to run the test case simultaneously.

If you choose to use activesync, then use it after you’ve created and saved your base image, if possible.

Hope this helps!

Dave Field, CISSP, MCP
Device Management and Security Architect
Enterprise Mobile, Inc.

Windows Mobile Device Emulator - Installment 1 - Setup and Use

Wednesday, May 14th, 2008

The following is the first of 2 installments that describe how I use Windows Mobile Device Emulators.  This installment covers setup and basic use while the second installment covers configuration.

A lot of people test and demo Windows Mobile devices using actual devices.  This works fine for most scenarios.  However, there are some distinct advantages to using device emulators:

·         The device emulators are free as they come with the Windows Mobile SDKs.

·         If you use a device emulator for your demo, you don’t need to use an Elmo overhead projector to show what’s happening on the device.

·         You can pre-configure a device emulator, save the pre-configured state and quickly “reset” the emulator back to the pre-configured state.  This is a real time saver for both demoing and testing.

·         You can test across multiple versions of the Windows Mobile Operating System simultaneously on one PC

If I’ve convinced you that the device emulator is worth setting up, follow these steps.

First, install the various Windows Mobile SDKs which include the device emulator images you will need to use:

·         WM 5.0 Emulators:  PPC and  Smartphone

·        MSFP Emulators - Note: This site allows download of the stand alone device emulator manager (v1emulator.zip) as well as the MSFP emulator images (efp.msi)

·        WM 6.0 Emulators

·        WM 6.1 Emulators

Next, you will need the Device Emulator Manager which comes integrated in Visual Studio (go to Tools/”Device Emulator Manager”).  If you don’t have Visual Studio, you can download the standalone Device Emulator Manager from the same download location as the MSFP Emulators.

Now, open the Device Emulator Manager which will show all the emulator images you’ve installed (see below). 

Device Emulator Manager

Note that the MSFP images do not automatically show up in the device emulator manager like all of the other emulator images.  MSFP images only show up after they are opened from the start menu (start/” Microsoft Windows Mobile 5.0 MSFP Emulator Images”).  Once the MSFP image is opened, it shows up in the “other” branch as an image GUID.  You may need to click the “refresh” button after the image is open to see it as shown below.

Now, open the image by “connecting” to it.  Right-click the image and select “connect”.  This will open the emulator in it’s own window.  Notice that you can open many emulators all it once by repeating the connect process for all of them.

You can connect the emulator to desktop activesync or WMDC if you want.  I recommend avoiding it, if possible.  ActiveSync connections can muck with work/internet settings and will automatically configure a proxy setting which may not be correct.  For instance, our proxy uses an outbound port of 8080 for HTTP traffic and ActiveSync configures use of port 80 which does not work.  But, there are some tasks that require use of ActiveSync.  To do it, you need to set Connection Settings to support a “DMA” connection type:To initiate the activesync connection, right-click on the image in the device emulator manager and select “cradle”.  Check back for installment 2 that will discuss the device emulator configuration that I use for testing.WMDC Connection Settings for Device EmulatorTo initiate the activesync connection, right-click on the image in the device emulator manager and select “cradle”.Check back for installment 2 that will discuss the device emulator configuration that I use for testing

Dave Field, CISSP, MCP

Device Managment and Security Architect

Enterprise Mobile, Inc.

SCMDM Sessions at TechEd North America 2008

Friday, May 2nd, 2008

For those going to the upcoming TechEd North America 2008, IT Pro Conference, June 10-13 in Orlando Florida my Enterprise Mobile colleague Patrick Salmon has two sessions just about SCMDM:

image

My other Enterprise Mobile college Doug Field, is managing the Hands-On-Lab for SCMDM as well!

Find more information on TechEd 2008 here:
http://www.microsoft.com/events/teched2008/itpro/default.mspx

There is also a ton of sessions on Windows Mobile and Windows Mobile 6.1 that could be very interesting!

Marco Nielsen
mnielsen@enterprisemobile.com

SCMDM Article in Smartphone/PocketPC Magazine June 2008

Friday, May 2nd, 2008

Another great article in the current issue of Smartphone/PocketPC Magazine from my colleague Patrick Salmon. Check it out here:

http://www.pocketpcmag.com/cms/_archives/Jun08/SystemCenterDevice

Good round-up of knowledge skills and necessary to get started with SCMDM. Provides an excellent overview of the technology and why it is important as well!

Marco Nielsen
mnielsen@enterprisemobile.com