Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common C# source code for Windows and Windows Mobile

I have a goal to build an application with UI that would run on both Windows Mobile and "normal" desktop Windows. The priority is for it to "look good" under Windows Mobile, and for desktop Windows it is OK if it distorted. Before I invest days trying, I would like to hear if that is possible to begin with. There are several parts to this question:

  1. Is .NET Compact Framework a subset of "normal" (please, edit) .NET Framework? If not, does MSDN have any information anywhere on classes that are in .NET Compact Framework, but not in "normal" (again, please, edit) framework?

  2. Is behavior of shared classes same in both frameworks?

  3. Is it possible to have a single Visual Studio 2005 solution / project for both platforms? If yes, how do to set it up?

  4. Any other comments and advice? Any relevant links?

like image 810
Ignas Limanauskas Avatar asked Dec 02 '08 04:12

Ignas Limanauskas


3 Answers

  1. The CF contains a subset of the full framework (FFx), but it is not a pure subset. There are actually several things available in the CF that aren't in the FFx, which makes it a bit more difficult. CF apps also, except in the most rudimentary cases, use P/Invoke. Those calls are never the same from the desktop to the device, so they are not directly portable (though with a little abstraction you can have a platform-agnostic interface).
  2. For the most part, behavior is the same. I've seen some cases where it's not, and I recall some event ordering not always being identical though, so trust but verify.
  3. It's possible through very careful massaging of the configurations, but I certainly don't recommend it. It's difficult to maintain and very fragile. Instead have two project files, one for CF and one for FFx. You're likely to have code file differences anyway. Add the code files as links to each project so they both use the same physical source file. I'd recommend using some form of CI to help ensure they both build at all times.
  4. Take a look at Dan Moth's MSDN article and blog entries on sharing code assets.
like image 149
ctacke Avatar answered Oct 30 '22 07:10

ctacke


P.S. I found the poster online - it'll show you all the classes that are CF. I ordered it fro Microsoft because Kinkos wanted $65 to print it out in color for me! Microsoft sent me a couple of copies free - all I had to do was ask:

http://www.microsoft.com/downloads/details.aspx?familyid=7B645F3A-6D22-4548-A0D8-C2A27E1917F8&displaylang=en

I have it hanging in my cubicle and it's a godsend when trying to remember which namespaces classes can be found in.

like image 21
BenAlabaster Avatar answered Oct 30 '22 07:10

BenAlabaster


Nice multi-part question:

  1. Differences between the Full Framework and the Compact Framework
  2. The article above has links to relevant documentation about how class behavior differs (it definitely DOES differ in some situations)
  3. Very simple! Create a single solution with a set of base functionality in a Class Library, then create two client projects (one for your desktop app and one for the windows mobile app). Finally, add references to the class library to both client projects.
  4. Depending on the breadth of the project you are working on, you may want to check out the Model View Controller pattern. It may be a bit much for your project, but if you want to share UI behavior between projects, it can be a life saver.

Hope that helps!

like image 42
Zachary Yates Avatar answered Oct 30 '22 05:10

Zachary Yates