locked
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

Answers

  • 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:

    http://social.msdn.microsoft.com/forums/en-US/windowsmobiledev/thread/e2b185b7-c5d9-4a7c-9370-22ff6eafc0a0/ 

    http://forums.msdn.microsoft.com/en-US/vssmartdevicesvbcs/thread/110181dc-8a2d-416c-9f62-f4c6ed2092fb/ 


    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:

    http://msdn.microsoft.com/en-us/magazine/cc163387.aspx




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


    Thursday, December 25, 2008 3:58 PM