Speed Up Your Windows Mobile Builds

Speed Up Your Windows Mobile Builds

One of the things that continually frustrates me about building Windows Mobile applications in Visual Studio is that for some reason it takes so long to do a build. Behind the scenes there is a lot that goes on and I always forget that there is one part of the build that you can mostly do without, the platform verification.  As pointed out by the now quite old post by the Visual Studio for Devices team you can disable this part of the build quite easily:

1) Open the file %windir%Microsoft.NETFrameworkv2.0.50727Microsoft.CompactFramework.Common.Targets for editing.

2) Go to the line which reads:
and change it to:
Name="PlatformVerificationTask" Condition="’$(SkipPlatformVerification)’ != ‘true’">

3) Add the SkipPlatformVerification environment variable to the system and set it to "true" (To re-enable Platform Verification set the environment variable to "false")

4) Restart Visual Studio for the changes to take effect (If building from the command line using MSBuild, add /p:SkipPlatformVerification=true to your command line to turn off the task. You can specify the variable in the project file also, so that this information is persisted across sessions).

As noted by Thomas you may just want to disable this functionality, instead of having it contingent on an environment variable.  In this case just change the PlatformVerificationTask line to:

Name="PlatformVerificationTask" Condition="false">

Doing this you should notice that your mobile projects build just as fast as other projects within Visual Studio.  Note: This is still relevant in Visual Studio 2008 with SP1.

WCF on Windows Mobile and .NET Compact Framework

WCF on Windows Mobile and .NET Compact Framework

I was just listening to Don, Dave and James on the second of the Jumpstart series for the Codemasons’ Guild and the topic of communicating via WCF came up.  Now typically when I build mobile apps I don’t go through all the pain of using WCF, I simply use a regular asmx web service and then use Add Web Reference to add it to my mobile project.  To secure it, I just communicate over SSL. If you do want/need to use WCF on the server side, there are a couple of options to do this.

Before we jump into how you use WCF, let me point out a couple of useful powertoys:

The Power Toys for .NET CF include NetCFSvcUtil.exe which is a device equivalent of SvcUtil.exe and is needed in order generate the WCF proxy.

Firstly, you need to be aware that the .NET CF has some severe limitations when it comes to WCF.  Unfortunately the only binding that is supported (excluding the much over-hyped WCF via Exchange) is basicHttpBinding. For the WCF service you want to consume you need to change it from using the default wsHttpBinding.  This can be done by launching the Tools > WCF Service Configuration Editor from Visual Studio. Open the web.config file for the WCF Service project.  Under Endpoints, adjust the Binding to basicHttpBinding.


Save this change and run the WCF Service.

Now to the options…..

1) The first option is to use Add Web Reference.  This is by far the simplest approach as you can click Browse to: Web services in this solution.  Select your service and click Add Reference. 


Once you have added the reference you can call your service method the same way you would from a regular desktop application:

localhost.Service1 service = new localhost.Service1();
service.Url = service.Url.Replace("localhost", "");
return service.GetData(5, true);

Note: You have to change the “localhost” host name to something that can be resolved by the device.  I typically just use the ip address of the development machine.  Clearly for production you will want to specify this in a configuration file or make it a configurable setting within your application.

2) The second option is to use NetCFSvcUtil.exe to generate the appropriate WCF proxy information. Start by opening up the Visual Studio command prompt (Start > Microsoft Visual Studio 2008 > Visual Studio Tools > Visual Studio 2008 Command Prompt) and adding the path to the Compact Framework power toys:

>> set path=%path%;C:Program FilesMicrosoft.NETSDKCompactFrameworkv3.5bin

Navigate to the folder where you want the proxy files to be created and then use NetCFSvcUtil.  I figured this would be quite simple but it appears that somewhere between Vista SP1 and SP2 (and there are reports of this problem on Windows 7 too) a bug in NETCFSvcUtil surfaced preventing it from working.


As you can see the error message is really helpful:

Error: An error occurred in the tool.
Error: Error in the application.

Currently, there doesn’t seem to be a workaround for this.  Some people have had varied success by changing the parameters and return types of the service methods.  The one strategy I used that appears to work is to use a combination of SvcUtil and NetCFSvcUtil.

>> svcutil.exe c:tempWindowsMobileServicesMyDataServicesbinMyDataServices.dll

Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation.  All rights reserved.

Generating metadata files…

>> netcfsvcutil.exe tempuri.org.wsd tempuri.org.xsd
Microsoft (R) .NET Compact Framework Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version]
Copyright (c) Microsoft Corporation.  All rights reserved.

Generating files…

Now, include all the generated file into your mobile project.  You will also need to add references to System.ServiceModel and System.Runtime.Serialization.

In order to call your service method you can now write the following:

var binding = System.ServiceModel.BasicHttpBinding();
var endpoint = System.ServiceModel.EndpointAddress("");
Service1Client client = new Service1Client(new binding, new endpoint
return client.GetData(5);

So, the question is why would you go the second option?  Well if you actually look at the generated code, adding the WCF service using Add Web Reference adds a bunch of unnecessary fields.  When calling the method GetData there is a second parameter called “valueSpecified” which is little more than a flag to indicate if the first parameter was specified or not.  This is not required if you use the second option to generate the proxy information.

Late Notice: Windows Mobile Jumpstart #2

Late Notice: Windows Mobile Jumpstart #2

Jumpstart #2:

Getting started developing for Windows Mobile 6.5: developer tools, technologies, debugging and testing
Learn how to get started developing for Windows Mobile 6.5, what can be done with the new technologies and how to use your existing skills to start coding apps for Windows Mobile 6.5 phones via Windows Marketplace.
Register for the second Live Meeting

Date/Time: Friday, July 17 (today!!), 2009 1:00 PM Australia (East)


And so that you’re ready for the next session:

Jumpstart #3

Widgets: the new internet application
Get insight into the Widgets platform for Windows Mobile 6.5 and discover how to develop powerful Widgets that leverage today’s web experience in a new way.
Register for the third Live Meeting

Date/Time: Friday, 31 July 2009 12:30 PM Australia (East)

Spb Mobile Shell 3.0

Spb Mobile Shell 3.0

Frank posted about this a few weeks ago now but I didn’t want to repost it until I’d had a chance to use the new Spb Mobile Shell 3.0. If you’ve ever felt that the Windows Mobile interface is tired and stayed then this product will give your device a new lease of life.

3D carousel

Unlike some of the other interfaces that OEMs such as HTC have been working on, Spb Mobile Shell doesn’t seem to completely drain the system resources.  It works nicely on Windows Mobile 6, 6.1 and 6.5 from what I’ve seen and means that just about everything you want to do is just a few clicks or slides away.  At $29.95 this is a must!

Codemasons’ Guild for Windows Mobile Developer

Codemasons’ Guild for Windows Mobile Developer

Don has just posted some of the Q&A from last weeks jumpstart Live Meeting session.  I had a brief listen to the recorded session as I wasn’t able to attend the event and it provides a good roundup of what’s included in Windows Mobile 6.5 and the Marketplace.  The one question that I love, and we’ll hear again and again, is the following:

Q: If the application is available for free? what will Microsoft charge developer?

A: It will be charged as one of your signings

Microsoft’s stance on this one appears to be that there is a cost associated with signing and verifying your application.  Whilst they are prepared to cover 5 of these included in your registration for marketplace, there after you’re on your own, even for free applications. Unlike the iPhone where you have to use the AppStore to distribute your application, with Windows Mobile you can at least make the cab file available as a download from your website.  My suggestion is that if you are going to build free applications for Windows Mobile, build a simple application that provides an catalogue of all your free applications and provides a mechanism for downloading them.  Add this application to marketplace (using only 1 of your free apps) and there after just post your free applications to your blog, website etc and update the catalogue.

Oh, and the other question I love is:

Q: Is this a once off fees ?

A: 99 USD charge fee for 5 app signings

This answer is actually incorrect.  It’s $150 AUD!!! Why they can’t use the current exchange rate I don’t know but $150 is way too much imho for signing up to this service (For comparison, the AppStore I think was $115 AUD).

Microsoft Gestures

Microsoft Gestures

At the moment Microsoft is gearing up for another swag of mobile devices, this time running Windows Mobile 6.5 which finally has a base level of support for Gestures (Oh, and a mostly usable revamp to the default interface).  With all the hype given to WM6.5 by both Microsoft and those that follow what’s going on there, such as Mary-Jo, you’d think that there would be a host of new features for developers.  Well, think again…..

I commend Marcus for coming out with this post that is part 1 of a discussion talking about getting started with understanding and using gestures.  With gesture support in the base OS, you would ask “why do I have to write all this plumbing to get gesture support in my application?”  Why is it left to the community (again) to build controls that really perform well and take advantage of the device features?

In an interesting discussion with fellow device MVP, Chris Tacke, he mentioned that in a recent application he just used a custom control that he had written.  And by just I mean, he has a single control that can be configured to represent all your standard controls such as label, button, checkbox etc.  This is just one illustration of the lengths to which .NET CF developers have had to go to build rich user interfaces.

I agree with Mary-Jo that it would be nice to know whether Microsoft is going to enable mobile developers in the next release of the Windows Mobile platform.  Every WM developer I know has at least considered jumping ship to other fruity platforms…. please Microsoft, step up and give us some hope and support, instead of feeding us this dribble about how great WM6.5 is.