Tuesday, June 28, 2005

Confusion About .NET & .NET CF

I'm using Visual Studio 2005 b2 for my C# development. My current solution file contains both projects that are .NET 2.0 and .NET Compact Framework 1.0. It only recently became clear to me that the SmartPhone 2003 projects in VS2005 b2 are, in fact, .NET Compact Framework 1.0 (bear in mind that this is a different, more restricted API than just .NET 1.o).

To add a .NET CF 1.0 project to your solution with VS2005 b2, select the solution in the solution explorer->Add->New Project->Visual C#->Smart Device->SmartPhone 2003. You have just implicitly started a .NET CF 1.0 project :)

More frustrating things about developing for these phones:

(1) Again, there is no good documentation source that simply displays the .NET CF 1.0 API. You have to wade through all of the .NET documentation and then scroll down to the bottom of the class description to make sure it's supported by your flavor of .NET.

(2) When you open up any class in VS2005 help, the bottom of the class description details three things.
  1. Development Platforms
  2. Target Platforms
  3. Version Information

The Version Information is most critical for .NET CF developers. It is here that Microsoft tells us whether or not this class is supported by the .NET CF framework (and which versions 2.0, 1.0, etc.). Of course, this does not mean that ALL members of this class are supported by the .NET CF framework; in fact, more often than not only a subset of the members are supported. So, you must then browse to the class members and look for the little Pocket PC icon. If it exists to the left of a method/property, you can be assured that it is supported by the .NET CF.

Now, this post is NOT a rant about the lack of functionality in .NET CF (of course the compact framework is going to have a more constrained API offering) but rather in the organization of the MSDN help system. After programming in .NET for the SMT5600 for only two weeks I have run into a couple of confusing instances where a method I expected to be available (e.g. the Control.ControlAdded event in Forms) was not and, critically, it took some proactive documentation perusing to understand why.

Finally, I will say that part of my struggle is most definitely a result of being relatively new to .NET as a whole (my Master's thesis project was in Java, my language of choice) -- there are inevitable growing pains and disconnects whenever learning a new language; it's just been a very frustrating experience.

2 comments:

Anonymous said...

I think there's some confusion here. A Smartphone 2003 project doesn't automatically give you a .NET CF 1.0 project - it gives you a .NET CF 2.0 project. To explicitly have a .NET CF 1.0 project, choose Device Application (1.0) project in the New Project dialog.

If you have any more questions, mail me at sriramk AT microsoft.com

Sriram Krishnan

Anonymous said...

Oh damn - stupid me. The automatic 2.0 project is for 2005 and not for Smartphone 2003. The (1.0) after each project type is supposed to serve as a hint

Sriram