# Monday, August 23, 2010

DataContractSerializer and Internal types

Under Silverlight only public types may be serialized with the DataContractSerializer. If you want to make your data classes internal to your assembly and serialise them for use in a WCF service you will find that the service call will fail at runtime with a SecurityException inside a misleading exception about inability to communicate with the service. There is a workaround however which involves exposing your internal types to the Silverlight base class libraries with the InternalsVisibleTo attribute. Simply add the following code to your AssemblyInfo.cs file:-

  1. [assembly: InternalsVisibleTo("System.Runtime.Serialization, PublicKey=00240000048000009400000006020000002400005253413100040000010001008d56c76f9e8649383049f383c44be0ec204181822a6c31cf5eb7ef486944d032188ea1d3920763712ccb12d75fb77e9811149e6148e5d32fbaab37611c1878ddc19e20ef135d0cb2cff2bfec3d115810c3d9069638fe4be215dbf795861920e5ab6f7db2e2ceef136ac23d5dd2bf031700aec232f6c6b1c785b4305c123b37ab")]

If you use the DataContractJsonSerializer you must also add the System.Servicemodel.Web assembly (the public key is the same).

#    |
# Monday, July 05, 2010

Review: .NET Compact Framework 3.5 Data Driven Applications

0102_MockupCover_0 Like Peter Nowak I was asked to review this recent release. Unfortunately due to other commitments it has taken the best part of a month to finish it. To avoid repeating the same points I recommend you read Peter’s review. While the current focus at Microsoft is on the upcoming Windows Phone 7 platform, we should not forget that there is still a demand for line of business applications for custom Windows CE platforms and Windows Mobile (and its Windows Embedded Handheld offspring) for enterprise devices.

I think the format of following a real-world application through the book provides a nice thread to tie together the various concepts described but often with this kind of approach you find features are shoe-horned in to show off a particular technology – a good example in this case is the IrDA/Bluetooth transfer of accounts between agents in a Sales application. Peter noted that the book does not describe the current situation with Visual Studio 2010 and why 2008 is needed for .NETCF 3.5 development but I think this is excusable based on the timescales involved in writing a book and how clearly this message was communicated by Microsoft.

The application design focuses exclusively on Windows Mobile and doesn’t cover issues when targeting other Windows CE platforms (such as Windows Mobiles enforced single-instance versus Windows CE default support for multiple instances of an application or just difference between the shells and screen layout). It also doesn’t cover form rotation and design for different DPI screens or implemented a locked-down kiosk mode. A personal gripe is the use of a SerialPort to do a Bluetooth transfer which is not the nicest solution, but then I suppose I’m biased.

Ultimately there is some good content in the book but it is unfortunately let down by being late to the party and the application scenarios try too hard to be all things to all people and ultimately not always 100% believable. It provides a starting point to work from and introduces a lot of functional areas from data synchronisation through to automatic update.

#    |
# Tuesday, June 22, 2010

Microsoft Surface Bluetooth Connect Code Sample

APPA Mundi recently worked with the Microsoft Surface team to put together a code sample showing the exchange of information from a Surface to a nearby Bluetooth enabled phone using standard protocols. This means that any phone which supports standard Object Exchange (OBEX) protocols can receive items from the Surface without installing any client software.

The sample code is available in the MSDN Code Gallery:-

http://code.msdn.microsoft.com/surfacebluetooth

This code sample is designed for use with the Microsoft Surface 1.0 SP1 SDK and makes use of the .NET Bluetooth library binary file available from http://32feet.codeplex.com. The sample code is provided "as-is" and is not supported. Alongside the standard functionality in 32feet.NET the sample illustrates using the notifications supported in the desktop Windows API and shows how to consume these from within a WPF application (the API uses native Windows messages).

#    |
# Thursday, June 17, 2010

New Book on .NETCF 3.5 Development

0102_MockupCover_0 Despite Windows Phone 7 Development being all-the-rage at the moment I was recently informed of a new book on .NET Compact Framework development. I’ll be reviewing it shortly, in the mean time you can check out the details (including a free chapter download):-

.NET Compact Framework Data Driven Applications

#    |
# Wednesday, June 16, 2010

DDD-Day Sydney 17th July

Following the format of the excellent Developer-Developer-Developer-Day events in the UK, Lewis Benge is organising an event on 17th July in Sydney. If you are in the Sydney area then I urge you to check out the website and register for this free event:-

http://www.dddsydney.com

As well as a range of .NET topics there will be a Windows Phone 7 session and labs.

#    |
# Monday, May 24, 2010

070-580: Windows Mobile 6.5 Application Development

This may be a little late to the party but I thought I would share some information on this exam. Because you sign an NDA when you take the exam I cannot comment on specifics of the exam content, however I can offer some guidance on the study guide:-

http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-580

This exam replaced the previous 070-540 exam which covered application development using Windows Mobile 5.0, .NET Compact Framework 2.0 and Visual Studio 2005. Therefore a large percentage of the material is the same between the two. The new topics come in the form of Widgets, LINQ, ADO.NET Sync Services and Windows Mobile Tools such as FakeGPS. The full list of skills measured can be read on the exam link above. There are a couple of oddities:–

  • The material is updated for .NETCF 3.5 by including LINQ but WCF is not listed.
  • ADO.NET Sync Services has never really been a core part of the development tools.
  • Finally one of the skills measured is creating a desktop installer for your application. There is not standard way of doing this but the guidance does exist (see list below) to put together a dll which acts as a custom install action within your desktop installer.

So once you’ve familiarised yourself with all the skills measured you’ll skip to the next tab on Preparation Materials and find there is nothing at all listed. Here is a list I think will help with your preparation:-

Microsoft Mobile Development Handbook – Microsoft Press. While the main book covers .NETCF 2.0 and Visual Studio 2005, the last chapter gives a run down on new features in Visual Studio 2008 and .NETCF 3.5 including LINQ. It ticks almost all of the Skills measured, there are a few articles which cover the new topics:-

Developing Widgets for Windows Mobile 6.5 – MSDN. The Windows Mobile 6.5.3 SDK added some support for Widget development to Visual Studio 2008 but I find it just hangs Visual Studio. This article shows the “old” approach from creating the HTML, JavaScript and building the ZIP file and renaming.

Programming Microsoft Synchronization Services for ADO.NET (Devices) – MSDN. Andy’s article describes Synchronization services from setting up and running synchronization through to optimisations for mobile use.

Using the FakeGPS Utility – MSDN.

 

The 70-580 exam is quite new and it is quite clear that if and when there is an exam created for Windows Phone 7 development it will by necessity be completely different. However for now 70-580 is the most up-to-date Microsoft exam for Mobility and is one of the requirements for the Mobility competency within the Microsoft Partner Program. Currently it doesn’t appear that there are any exams at all for Silverlight, but there are some coming in the next few months for .NET 4.0 and WPF.

#    |
# Friday, May 14, 2010

Microsoft English 1.0

More proof (if really needed) that Microsoft is abandoning English and making up its own language:-

"We have noted your concern and we have given your feedback to our upstream."

From Microsoft Subscriptions Support (TechNet/MSDN)

#    |
# Monday, May 10, 2010

Mobile In The Hand 4.2 Released

This latest update includes a number of performance enhancements and wider device compatibility.

A new SystemEvents class is added in the InTheHand.Win32 namespace which allows you to monitor power changes on devices which do not support the State and Notifications Broker (Pocket PC 2003 and all Windows CE devices).

InTheHand.Net.WebUtils provides a method to safely encode/decode strings in a HTML/XML friendly way.

InTheHand.WindowsMobile.Status.SystemState now supports more properties on Pocket PC 2003 and Windows CE devices by interfacing with lower level APIs on these devices.

This is a free update from v4.x. Registered users of v3.x can purchase a reduced price upgrade. Full product details here:-

http://inthehand.com/content/mobile.aspx

 

#    |
# Tuesday, May 04, 2010

WP7: Versions in April CTP

I was surprised when I first wrote a hello world application on the MIX CTP that the Environment.OSVersion.Version property was returned as 7.0 when all the media speculation was that it would be based on CE 6. I tweeted about it at the time but some sources are still saying that it runs a customised version of Windows Embedded CE 6.0 R3. However regardless of whether this is a version which pre-dates the eventual release of Windows Embedded Compact 7 (which will be the new name for the successor to Windows Embedded CE 6.0) and any other name changes (remember we have already had Windows CE, Windows CE.NET and Windows Embedded CE) I think it’s safe to say that the core OS in the product is version 7. As we already know Silverlight (and XNA) runs on top of the .NET Compact Framework 3.7 runtime. So just for curiosities sake here are the version properties retrieved in the latest April CTP release:-

April CTP Versions

#    |
# Monday, May 03, 2010

Configuring Microsoft Exchange Server for Mobility

If you want to learn about configuring Exchange Server for mobile devices there is an interactive configuration guide which will work through the actions required depending on your platform and your specific requirements:-

http://wmexchangesetup.com/launcher.aspx

#    |
# Saturday, May 01, 2010

WP7: Writing a Well-Behaved Threaded Application

The latest CTP release of Windows Phone 7 introduces a new managed library which exposes events you can monitor to catch changes in state in your application. The assembly is Microsoft.Phone.Execution.dll. This contains a WindowsPhoneEvents class which exposes two static methods – Pause and Resume. You can handle these events to detect when your application is dismissed and reactivated. This allows you to stop unnecessary processing and be a good citizen. I put together a simple example which shows how to pause a background thread based on these events and you can see the results by running it on the Emulator and switching to the home screen (Windows button) and returning to your application (Back button).

The sample uses a ManualResetEvent to block the background thread to avoid it consuming processor cycles while the app is paused.

WindowsPhoneThreading.zip (22kb)

 

Also in this assembly is the StreamPersister class. Unfortunately there is no documentation for this at the moment but an instance is passed in the Pause and Resume eventargs which will presumably allow you to safely persist state data which you can then load when your app is resumed. Hopefully there will be some official documentation on this to complete the picture.

#    |

WP7: New Capabilities Security Model

Jamie Rodriguez has a post on the new capabilities security model in Windows Phone 7 which is introduced in the latest CTP release:-

http://blogs.msdn.com/jaimer/archive/2010/04/30/windows-phone-capabilities-security-model.aspx

It is interesting to read how this will be handled at runtime, here are the key facts:-

  • If you try to use a feature and you didn’t specify the capability you’ll get an UnauthorizedAccessException when you first call that feature
  • There is no API to check if you have been granted a specific capability
  • The disclosure to the user will vary depending on the capability and marketplace – Either listed on the Marketplace page, a user prompt at purchase or a user prompt when the capability is about to be accessed.
  • A new project created in the latest CTP will request all of the currently documented capabilities (you can remove those you don’t need later)
  • There are other capabilities specific to OEMs and operators which are not documented
  • The table of example features lists a few items yet to be shipped in the developer tools giving an interesting insight into what is still to come – Microsoft.Devices.Radio and Microsoft.Devices.MediaHistory
#    |
# Friday, April 30, 2010

WP7: New CTP and a quick tip

If you haven’t already heard there is a new release of the Windows Phone 7 Developer Tools available which is compatible with the RTM release of Visual Studio. Before you install you need to uninstall the previous version and this is where you might have problems. See this tool for cleaning up your machine:-

http://blogs.msdn.com/astebner/pages/9544320.aspx

Okay, now you’ve safely removed the old bits you can download the new installer from here:-

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=cabcd5ed-7dfc-4731-9d7e-3220603cad14

Read the release notes:-

release notes

In particular there is a breaking change if you open existing projects – the WMAppManifest.xml requires some extra items to describe the application’s capabilities. There is also an issue with including Authenticode signed dlls (this includes official Microsoft libraries), you can read more about it here:-

http://timheuer.com/blog/archive/2010/04/29/windows-phone-tools-update-april-2010-silverlight-xna.aspx

Check out an overview of what is new in this release:-

What's New in Windows Phone 7 CTP Refresh

 

Finally to end on a quick tip – Assuming you install on a machine without Visual Studio 2010 the “Visual Studio 2010 Express for Windows Phone” displays a simpler user interface than its big brother. You can quickly enable extra goodness by going to Tools > Settings > Expert Settings. This enables more menu and toolbar options and is definitely worthwhile if you are already familiar with Visual Studio.

#    |
# Tuesday, April 13, 2010

WP7: ApplicationBar CTP Issue

If you have read the UI Guidelines for Windows Phone 7 (If you haven’t, get it now) you notice that in the discussion of the ApplicationBar it states that a maximum of four icons can be added. I noticed inadvertently that if you add five icons in your XAML your app will compile and run but only the first four are shown. If you add a sixth icon the designer will present you with an error:-

appbar6items

It appears that this is a bug in the current CTP release and the control should support only adding four items. It previously supported five but this was reduced based on user feedback, obviously the validation in the current CTP is not strict enough but I expect this will be fixed in the next release.

#    |

KIN: A totally different Windows Phone

Microsoft announced a pair of new phone devices which will be manufactured by Sharp and branded KIN. These are not part of the Windows Phone 7 platform but are still (perhaps confusingly) called Windows Phone. KIN uses a lot of the same underlying technology as Windows Mobile has in the past and Windows Phone will do, however the device is sharply focussed on social networking and the whole user experience revolves around this. The platform has built in support for Facebook, Twitter and MySpace along with the accompanying KIN Studio online service. KIN Studio is a web portal which aggregates everything you create on the phone up in the cloud. It has some cool visualisation of this content too including a timeline view of everything you’ve done. Think of it as a kind of MyPhone on steroids…

16_web

The user experience uses some of the same principles as the Metro user interface visible in Windows Phone 7 however one thing that is instantly noticeable is there is a lot less dead space. Where Windows Phone 7 uses large fonts and generous spacing in a “less is more” approach the KIN user interface packs highly graphical elements closely together. It has been described as a magazine style and certainly tries to catch your eye with everything which is going on in your social networks. Both platforms use a minimal colour scheme – from the flash based demo on the website you can choose one of four highlight colours but these are different to the colours used on the “big brother” Windows Phone 7.

I’m looking forward to seeing the real device, and I hope that some of these innovations (particularly KIN Studio) make it into Windows Phone 7 too! I’m also wondering if there will be any development story for these devices as there is nothing mentioned on the official website or press releases…

#    |
# Friday, April 02, 2010

Introducing "Windows Phone 7"

Microsoft have announced via Twitter that they have officially dropped the epic fail "Series" from the product name. Many have been referring to it as "Windows Phone 7" or "WP7" already and the "Series" was the latest in a series (sorry) of Microsoft adding redundant words to product names to unnecessarily confuse the public...

#    |