.NET Compact Framework Development mini-FAQ

Printer-friendly versionPrinter-friendly version

Development

An attempt to call XmlSerializer.Deserialize() throws an InvalidCastException

Mostly happens when de-serializing containers of classes. As a result, a container with System.Object instances is produced. This is caused by absence of default constructor in the class that is stored in the container. Surprisingly, when developing a full .NET application, the compiler does detect this problem and issues a warning (not the case when developing .NET CF apps).

Related issue - an exception caused by "data error" pointing to the start of the first contained data in the XML file.

Deployment

This application requires newer version of the microsoft .net compact framework

Self-explanatory. Most common cause: the app was built using .NET Compact Framework 2.0 and is being deployed on a device running version 1.0 (e.g. on a Windows Mobile 5.0 device)

Possible solutions:

  • Install .NET CF 2.0 Redistributable on the device.
  • Backport the application to .NET CF 1.0 (which is usually a big pain considering what immature piece of junk v1.0 used to be).