P/Invoke Wizard, available from The Paul Yao Company, for help in creating declarations needed to call native code from the .NET Compact Framework.Should you upgrade to this latest version (or whatever later version might be available by the time you read this)? We must say yes! This is a new technology, and the .NET Compact Framework team is still working on improvements and upgrades to make the library work better and faster. After shipping a new library, the .NET Compact Framework team members—like most development team members at Microsoft—take a weekend or two off, and then their reward for their hard work is that they get to start all over again, working to create something even better. It’s a good thing that they like what they are doing—and that they are so good at it.Some samples are written in C++, using the Windows API (also known as Win32).Within the three samples directories (..\CS, ..\VB, and ..\CP) you find a directory for each chapter. Within each chapter directory you find another set of directories for all the samples in that directory.
For example, one of the samples in Chapter 5 is named “FormEvents.” The C# version is at this location: ..\CS\Ch05_CreatingForms\FormEvents. The Visual Basic .NET version is at this location: ..\VB\Ch05_CreatingForms\FormEvents.
The Target Audience for This Book We wrote this book to help programmers with the .NET Compact Framework. We assumed that no prior programming experience with Windows 95/98/2000/XP, with Windows CE, or with .NET was required. At the same time, if you have experience with programming for Windows on the desktop, with Windows CE, or with the .NET Framework, that experience will help you.
For Programmers Experienced with Windows CE If you already have experience writing Windows CE programs, you might be wondering if you even need to use the .NET Compact Framework. Whether you do or not depends on what tools you have been using and what type of work you expect to do.
If you have been using eMbedded Visual Basic (eVB) to write Windows CE programs, you are probably already aware that Microsoft plans to discontinue support for eVB. As of this writing, the Pocket PC 2003 supports eVB; that is the last platform to be supported. The .NET Compact Framework is a great replacement. It is well designed, and it provides Visual Basic programmers with support that puts them on a level playing field with C# programmers.
If you have been using the Microsoft Foundation Class (MFC) Library, the ActiveX Template Library (ATL), or the Windows Template Library (WTL), then the case for the .NET Compact Framework is still pretty good. Chapter 1 describes the .NET Compact Framework and its benefits. The new .NET programming paradigm provides many benefits for programmers who have worked with other frameworks. Getting involved with .NET Compact Framework programming is a great way to get into the world of .NET because the libraries are scaled back from the (sometimes) overwhelming number of classes and features found on the desktop .NET Framework. And there is an added bonus for making the move to the .NET Compact Framework: The fundamental elements of programming for the .NET Compact Framework programming are the same as the fundamental elements for all .NET-based technologies. So learning the .NET Compact Framework today will help you learn to build Web applications using ASP.NET, Windows Forms applications for the desktop, and managed-code stored procedures for Yukon (the code name for the next version of SQL Server).
If you have been using the core Windows API/Win32, then you might wonder whether to continue writing Win32 code or to jump into the .NET Compact Framework. For some things, including the following, you must continue using Win32.2
- Fastest executables
- Best real-time support
- Source code portability between platforms
- Ability to wrap Component Object Model (COM) for access by .NET Compact Framework applications
- Ability to create device drivers
- Ability to create control panel applets
- Support for custom user interface skins
- Support for security extensions
- Ability to build Simple Object Access Protocol (SOAP) Web Service servers
- Support for Pocket PC shell extensions
- Ability to use existing Win32 code
For Programmers Experienced with the .NET Framework If you are experienced with writing programs that use the .NET Framework, you are going to find much that is familiar. The C# and Visual Basic .NET languages, for one thing, use the same syntax for two very popular languages that are available for desktop .NET development. The fundamental data types that support interoperability between different languages on the desktop also play a core part of interoperability with smart-device programs.
One thing that may be surprising to desktop .NET Framework developers is the extent to which they might need to rely on P/Invoke support to call the underlying Win32 API functions that Windows CE supports. While the desktop .NET Framework provides an extensive set of classes that minimizes the need to call outside the framework, the .NET Compact Framework provides a reduced set of classes to meet the size constraints of mobile and embedded devices.
To help programmers move from the .NET Framework to the .NET Compact Framework, throughout the book we provide some detailed discussions of differences between the two frameworks. In the many workshops we have taught, we have observed the knowledge and skills of programmers who are experienced with the .NET Framework transfer quite readily to the .NET Compact Framework.
The primary challenge comes from an experience we refer to as “stubbing your toe”—tripping over a familiar desktop feature (whether a class, an enumeration, an attribute, or an operating system feature) that is not present on smart mobile devices. When this happens, you have found a limit on the support available in the .NET Compact Framework (or, perhaps, a limit on the support of the underlying Windows CE operating system). The attitude you take in dealing with such experiences will play a big role in determining how successful you are in .NET Compact Framework programming—and how enjoyable you will find it. We have observed that the programmers who excel with device development are the ones who are able to see in these limitations an enticing challenge and an opportunity to explore new ways to solve old problems.
We extend our very best wishes to you on your .NET Compact Framework development, whether for the Pocket PC, the Smartphone, or some other Windows CE-powered smart device. We look forward to seeing you in one of our workshops or at an industry conference, or trading comments with you online (contact us via e-mail at info@paulyao.com).
Paul Yao, Bellevue, Washington
David Durant, Goldendale, Washington
March 2004
Notes1. Historically, not all emulators have provided high fidelity to device software. In particular, Windows CE 1.x and 2.x emulators were based on an older technology that was good but not great. The last emulator to use this older technology was the Pocket PC emulator that shipped with Microsoft eMbedded Visual C++ 3.0. All emulators for Visual Studio .NET 2003 use the newer emulation technology.
2.
0321174038P05132004