Is it possible to convert projects from desktops to devices? RRS feed

  • Question

  •  Is it possible to convert projects from desktops to devices?

    Thursday, December 25, 2008 3:42 PM


  • Firstly, as we know, the compact framework is a subset of the full .net framework.  In fact, the .NET Compact Framework is not a strict subset of the .NET Framework; it actually adds some members of its own. There are four device-specific assemblies: System.Data.SqlServerCe, System.Net.IrDA, Microsoft.WindowsMobile.DirectX and Microsoft.WindowsCE.Forms. What desktop developers usually do when trying to port an application to a mobile device is to take an assembly, built against the desktop framework, and reference it from a device project. This will not work and is definitely not supported. Even if your desktop project uses only types and members that are also available on the .NET Compact Framework, you will still get TypeLoadException and MissingMethodException exceptions at run time.

    Related issues:



    Secondly, although desktop assemblies cannot be executed on the device, the good news is that the reverse is possible. If you create a smart device project and build it, the output (the EXE or DLL) can be executed on the desktop and can be referenced by desktop projects. This works because the .NET Compact Framework assemblies are retargetable. If you open one of them with ILDASM, you will see that they have the System.Reflection.AssemblyNameFlags.Retargetable attribute.  This means that at run time all references to the .NET Compact Framework assemblies are retargeted to the desktop equivalents. So, to be clear, your assembly uses the desktop implementation, not the device implementation of the .NET Framework.

    Note: You can’t use device-special library, like Microsoft.WindowsCE.Forms etc.

    For more information please refer to:


    For more FAQ about Windows Mobile Development, please see Windows Mobile Development FAQ

    Thursday, December 25, 2008 3:58 PM