.NET Compact Framework 2.0


Introduction

The .NET Compact Framework brings the powerful programming environment of the .NET Framework to devices.

The .NET Compact Framework is a hardware-independent environment for running programs on resource-constrained computing devices, encompassing personal data assistants (PDAs) such as the Pocket PC, mobile phones, set-top boxes, automotive computing devices, and custom-designed embedded devices built with the Windows CE operating system.

  • The .NET Compact Framework is a subset of the .NET Framework class library and also contains classes exclusively designed for it. It inherits the full .NET Framework architecture of the common language runtime and managed code execution.
  • The .NET Compact Framework provides the following key functionalities:
  • Runs programs that are independent of hardware and operating systems.
  • Supports common network protocols, and connects seamlessly with XML Web services.
  • Provides developers with a model for targeting their applications and components to     either a wide range or specific category of devices.
  • Provides benefits of design and optimization of limited system resources.
  • Obtains optimal performance in generating native code using just-in-time (JIT) compilation.

This documentation assumes a general understanding of the .NET Framework. It focuses on technologies and components of special importance or that are unique to the .NET Compact Framework. Accordingly, this documentation does not repeat topics it has in common with the full .NET Framework. The .NET Compact Framework uses the same class library documentation as the full .NET Framework.

The .NET Compact Framework supports Visual Basic and Visual C# development. C++ development is not currently supported.

This article provides high level summary of .net compact framework

User Interface

The relatively small size of smart device displays requires that applications use the available space efficiently, which historically has required that developers spend a great deal of time designing and implementing an application’s user interface. Recent advances in smart display capabilities, such as high-resolution and multiple orientation support, have made the job of user interface development even more challenging. To simplify the task of creating application user interfaces, the .NET Compact Framework 2.0 provides the many new features that are described in this section.

Windows Forms Controls

At the heart of the user interface are the controls; the .NET Compact Framework 2.0 provides a number of new controls. These new controls consist of controls that the .NET Compact Framework has in common with the full .NET Framework in addition to controls that are specific to devices.

MonthCalendar

The MonthCalendar control is a customizable calendar control that provides a visual display of dates and is useful for providing a graphical way for users to select dates.

DateTimePicker

The DateTimePicker control is a customizable control for displaying and allowing users to enter date and time information. It is especially well suited for smart device applications due to its combination of a compact display and graphical date selection format. When displaying information, the DateTimePicker control renders similar to a text box; however, when the user is selecting a date, a pop-up calendar similar to the MonthCalendar control can be displayed.

WebBrowser

The WebBrowser control encapsulates the device Web browser, providing rich display capabilities and exposing a variety of events that allow your application to both track the user’s interaction with the Web browser content in addition to allowing your application to provide customized behaviors for these events.

Notification

The Notification control encapsulates the Pocket PC’s notification feature that allows applications to send the user a notification without changing the context of the user’s current activity. The notification text can be plain text or HTML. In addition to displaying information, notifications can receive input from the user by including HTML buttons and links in the HTML text of the notification.

DocumentList

The DocumentList control provides a standard mechanism for displaying and managing files such as that which is used when opening files in Excel Mobile and Word Mobile. The DocumentList control provides the user with the ability to navigate around the file system and to delete, copy, move, and rename files. The user can also use the DocumentList control to send e-mail messages and send files by means of infrared to other devices.

DataGrid on Smartphone

Smartphone now supports the DataGrid control. Just like Pocket PC, the DataGrid control on Smartphone supports configurable column sizes, multiple display styles, data binding, null value handling, and events to track user cell selections.

LinkLabel

The LinkLabel control is a label control that is capable of displaying one or more hyperlinks.

Splitter

The Splitter control is a splitter bar that provides resizing capability to docked controls.

ToolBar

The ToolBar control is Windows toolbar that is capable of displaying images as buttons.

User Controls

The .NET Compact Framework 2.0 now supports user controls. With the addition of user controls, .NET Compact Framework 2.0 applications can now create controls graphically within Visual Studio 2005 and, just as the full .NET Framework, the .NET Compact Framework 2.0 user controls automatically appear on the control Toolbox and can be placed on forms by using drag-and-drop.

Display and Layout Management

The wide variety of Windows Mobile form factors that are now available requires that application developers develop application user interfaces to be much more dynamic than in the past. To simplify the task of creating dynamic user interfaces, the .NET Compact Framework 2.0 provides many new layout and management features.

Control Docking

The .NET Compact Framework 2.0 controls now support docking. Docking a control places it against the edge of the parent control—filling that edge. As the parent control is resized, the docked control automatically resizes to always fill the specified edge of the parent control. Controls can also be docked to fill the entire parent.

Control Anchoring

The .NET Compact Framework 2.0 controls also support anchoring. Anchoring a control identifies that one or more sides of the control should remain a fixed distance from the corresponding edge or edges of the parent control. As the parent control is resized, the control automatically resizes so the anchored sides of the control remain the appropriate distance from the corresponding edges of the parent control.

Automatic Scrolling

The Form and Panel control—in addition to other controls that inherit from the ScrollableControl control—now provide the AutoScroll property. When set to true, the control automatically provides a scroll bar to allow the user to scroll to any child controls that are outside the control’s visible boundary.

Automatic Scaling

All ContainerControl derived controls, such as the Form control, now provide the AutoScaleMode property. The AutoScaleMode property indicates how the control should render when it is displayed on a resolution different than the resolution it was originally designed for. When set to AutoScrollMode.Dpi, all child controls of the container control are scaled to match the runtime display’s resolution. A value of AutoScaleMode.None indicates that no automatic scaling will be done, making the application responsible to render correctly on the different resolutions.

SuspendLayout and ResumeLayout

The .NET Compact Framework 2.0 Control class now supports the SuspendLayout and ResumeLayout methods. Just as in the full .NET Framework, these method are used in conjunction with one another to group multiple layout events, such as repositioning or resizing a series of child controls.

Graphics DpiX and DpiY properties

The Graphics class now provides information as to the resolution of the current device display. The DpiX property indicates the number of horizontal dots per inch, and DpiY indicates the number of vertical dots per inch.

Custom Drawing

To simplify the creation of rich user interfaces, the .NET Compact Framework 2.0 has added a number of features that allow applications to much more easily handle custom drawing.

Rotatable Fonts

The addition of the LogFont class to the .NET Compact Framework 2.0 provides support for displaying text at an angle and for incorporating other text effects.

Custom Pens

Applications can now create pens of a specific color and size.

Bitmaps

The .NET Compact Framework 2.0 provides many enhancements for working with bitmaps. Enhancements include providing more options when creating bitmaps and having the ability to save a bitmap to a file or stream.

Applications can more easily view and manipulate bitmaps through the combination of the LockBits and UnlockBits methods with the newly added BitmapData class. For applications needing to share bitmaps between managed and native code, you can now retrieve a handle to the native bitmap object through the GetHbitmap method.

DirectX

Windows Mobile 5.0 software includes a number of rich two-dimensional and three-dimensional drawing features through its native implementation of the DirectX application programming interfaces (APIs). For .NET Compact Framework 2.0 developers who target Windows Mobile 5.0–based devices, the DirectX feature set is available through the classes contained in the “Microsoft.Windows.DirectX” namespace and corresponding assembly.

Keyboard Management

An increasing number of smart devices now include keyboards. To allow managed developers to take advantage of the available keyboards, the .NET Compact Framework 2.0 provides enhanced support for keyboards.

Tab Support

Controls now support a tab order allowing application users to move between controls by pressing the tab key.

Keyboard Events and Form.KeyPreview

Controls now receive KeyUp, KeyDown, and KeyPress events. In addition, the Form control now provides the KeyPreview property. When set to false, keyboard events are sent directly to the control with focus. When KeyPreview is set to true, all keyboard events are sent to the Form instance prior to being sent to the control that currently has focus. The Form instance can prevent an event from being sent to the control with focus by setting the KeyPressEventArgs.Handled property to true in the Form instance’s corresponding event handler.

Data

Data is of course a central part of any application. Whether relational or XML, data-oriented classes have a direct effect on the level of programming effort that is required to access and work with data. The .NET Compact Framework 2.0 provides a number of new data classes in addition to new features to existing classes.

Updatable, Scrollable Access to SQL Server 2005 Mobile Edition

The .NET Compact Framework 2.0 provides a new class for accessing a SQL Server 2005 Mobile Edition (SQL Mobile) database, SqlCeResultSet. The new SqlCeResultSet class provides scrolling and updatable access directly to the SQL Mobile database. This access provides a much faster and more resource-efficient solution for accessing SQL Mobile data than the DataSet class. Like the DataSet class, SqlCeResultSet can be used as a data binding source.

DataSet

The DataSet class and related classes provide a number of new features. These features not only provide enhanced functionality but also bring the .NET Compact Framework DataSet class more inline with that of the full .NET Framework.

GetChanges and Merge Methods

The .NET Compact Framework 2.0 adds the GetChanges and Merge methods to the DataSet class. The GetChanges method returns a copy of DataSet that contains all of the changes since AcceptChanges was last called. The returned DataSet is optimized for merging.

The Merge method merges one DataSet into another. It is particularly useful for merging changes from one DataSet, returned by the GetChanges method, into another.

Copy Method

The .NET Compact Framework DataSet class now provides the Copy method. The Copy method returns a new DataSet containing the same structure and data as the original.

DataTables Serialization

The DataTable class now provides the WriteXml and ReadXml methods, which provide XML serialization and deserialization of individual tables. Also the addition of serialization and deserialization support allows DataTables to now be passed as Web service arguments.

XML

The .NET Compact Framework 2.0 provides a number of enhancements to the XML–related classes. These enhancements both simplify the process of working with XML data and also bring the .NET Compact Framework XML–related classes much more inline with those available in the full .NET Framework.

XPath Support

The XmlDocument class now supports the SelectSingleNode and SelectNodes methods—both of which provide the ability to search the document using XPath.

XML Serialization

The .NET Compact Framework 2.0 adds the XmlSerializer class along with the related attribute classes, such as XmlElement and XmlAttribute. Using XmlSerializer allows you to save and restore classes to and from XML.

The new XmlSerializer class is also used internally by the .NET Compact Framework 2.0 Web service proxy base classes. The new XmlSerializer class provides substantially improved performance over the mechanism used by the .NET Compact Framework 1.0 to serialize and deserialize Web service arguments thereby providing improved Web service call performance.

XML Schema

The .NET Compact Framework 2.0 now provides the XmlSchema class and related classes for working with XML schema documents. These classes can also be used to dynamically generate schemas.

Data Binding

The new data binding class, BindingSource, is included in the .NET Compact Framework 2.0. The BindingSource is normally layered between one or more data bound controls and a data binding source. When used, the BindingSource class simplifies data binding by providing a layer of indirection and adding currency management, change events, and more.

Communications

Communications is an important part of virtually every smart device application. The .NET Compact Framework 2.0 has added several new classes to simplify common communications requirements as well as providing entirely new capabilities. In addition to the new communications classes, the .NET Compact Framework 2.0 also includes improvements to existing classes.

Web Services

As noted earlier, the new XmlSerializer class substantially improves the performance of Web service calls by providing a much faster XML serialization and deserialization of Web service arguments.

In addition to the performance improvements, the .NET Compact Framework 2.0 Web service classes now provide support for SOAP version 1.2.

MSMQ

For application developers who want to take advantage of the asynchronous messaging features of MSMQ, the .NET Compact Framework 2.0 provides the classes in the “System.Messaging” namespace. These classes provide support for sending and receiving messages including using transactions to create atomic operations.

Serial Ports

To reduce the programming effort that is required when working with serial ports, the .NET Compact Framework 2.0 includes the SerialPort class. The SerialPort class provides a simplified abstraction over serial communications ports that provides a number of features that simplify monitoring and configuring serial ports. The serial port also simplifies sending and receiving data with serial ports—including the automatic encoding and decoding of data sent to and received from the port.

IPv6 Support

The .NET Compact Framework 2.0 networking classes now provide support for IPv6 in addition to IPv4.

Security

Security is an important consideration for all applications—including those running on smart devices. In addition to the security features provided by the Windows Mobile platform, the .NET Compact Framework 2.0 adds cryptography and network protocols.

Cryptography

The .NET Compact Framework 2.0 has added substantial cryptography support, such as MD5 and SHA1 hashing; RC2, RC4, 3DES, and DES symmetric encryption; and RSA and DSA asymmetric encryption.

Network Protocols

In addition to the support for Digest authentication provided by the .NET Compact Framework 1.0, the .NET Compact Framework 2.0 now provides support for both NTLM and Kerberos authentication.

Threading

Threading is an important part of many .NET Compact Framework applications. The .NET Compact Framework 2.0 has made several enhancements to threading-related classes to provide developers with more threading control and to make managing threads a little easier.

Thread Class

As you would imagine, the majority of changes made in the .NET Compact Framework 2.0 are on the Thread class itself. These changes provide applications with more threading control and bring the .NET Compact Framework Thread class more inline with that of the full .NET Framework.

Background Threads

The .NET Compact Framework 2.0 adds support for background threads. Background threads are threads that do not prevent a process from terminating whereas foreground threads will keep a process active until all foreground threads are terminated. Setting a thread’s IsBackground property to true makes that thread a background thread.

Aborting Threads

The .NET Compact Framework 2.0 threads now include the Abort method. When called, the Abort method raises a ThreadAbortException and normally terminates the thread.

Thread Coordination

A thread can now block waiting for another thread to complete by calling the thread’s Join method.

Thread Name

A thread can now be named by assigning a string name to the thread Name property. A thread can be named only once.

Threads and the User Interface

The .NET Compact Framework 2.0 now supports asynchronous execution of a delegate on a user interface thread. Unlike the .NET Compact Framework 1.0 that supports only the Control.Invoke method (which synchronously executes a delegate on a control’s owning thread), the .NET Compact Framework 2.0 provides Control.BeginInvoke that asynchronously executes a delegate on the control’s owning thread. The Control.EndInvoke method is also provided. When called, the EndInvoke method returns the results of an asynchronous operation.

Performance and Resource Management

In addition to the many new features and class library enhancements, the .NET Compact Framework 2.0 also provides substantial performance improvement over the .NET Compact Framework 1.0. These performance improvements affect virtually every area of application execution including the recovery of application resources.

Runtime Performance

The .NET Compact Framework 2.0 runtime has undergone a thorough examination and rework with the goal of improving performance. These improvements have paid off. Although its difficult to identify how the performance of any given application will be affected, many areas of the .NET Compact Framework 2.0 runtime perform nearly one-and-one-half times the speed of the corresponding operation in the .NET Compact Framework 1.0. Other areas provide even more significant such as method dispatching, both virtual and non-virtual, which is nearly two-and-a-half times faster than the .NET Compact Framework 1.0.

Data Class Performance

In addition to the overall runtime performance improvements, special attention has been given to improving the performance of the data classes. The .NET Compact Framework 2.0 DataSet class loads relational data nearly four times faster than the original release of the .NET Compact Framework 1.0. Even when populating the DataSet using the ReadXml method, the DataSet populates nearly three times faster.

The XmlTextReader class has undergone similar performance improvements and is now able to read the contents of an XML file nearly three times faster than the original .NET Compact Framework 1.0 release.

Releasing Application Resources

One of the areas where the .NET Compact Framework 2.0 has made some of the most significant performance improvements is in the garbage collector. In general the .NET Compact Framework 2.0 garbage collector is able to recover memory more than seven times faster than the .NET Compact Framework 1.0 garbage collector. Recovering large objects, such as an array of 100 integers, was already very fast in .NET Compact Framework 1.0 but has still been improved to collect data more than four times faster in the .NET Compact Framework 2.0.

Native Interoperation

Although the .NET Compact Framework 2.0 provides many enhancements, managed applications will still have the need to interact with native libraries on occasion. The .NET Compact Framework 2.0 includes several new and enhanced features that simplify interacting with native code.

Window Handles

All controls now expose their native window handles through the Handle property. The handle represents the native Windows object that corresponds to the control and can be passed to native methods that expect a window handle.

COM Interoperation

The .NET Compact Framework 2.0 applications can now create and interact directly with COM objects. Both late-bound and early-bound (vtable-based) method calls are supported. Although support for COM components creating and calling managed components is not supported, managed application can receive COM callbacks.

Data Marshaling

The .NET Compact Framework 2.0 data marshaling between managed and native code now supports many more data types than the .NET Compact Framework 1.0. No longer are parameters passed to native code limited to four bytes. Data types, such as long and float, are now fully supported—as are classes and structures containing embedded types such as strings and arrays. Marshalling behavior can now be customized by using the MarshalAs attribute.

Conclusion

Hopefully this summary has given you a good idea about the many new features available to smart device developers by using the .NET Compact Framework 2.0

.NET Compact Framework Downloads

Get all the downloads you need to run and develop .NET Compact Framework-based applications.

.NET Comapct Framework 2.0 Service Pack1 Redistributable

http://www.microsoft.com/downloads/details.aspx?familyid=0c1b0a88-59e2-4eba-a70e-4cd851c5fcc4&displaylang=en

.NET Comapct Framework 2.0 Redistributable

http://www.microsoft.com/downloads/details.aspx?familyid=9655156b-356b-4a2c-857c-e62f50ae9a55&displaylang=en

Visual Studio 2005

http://msdn2.microsoft.com/en-us/vstudio/default.aspx

Windows Mobile 5.0 SDK for Pocket PC

http://www.microsoft.com/downloads/details.aspx?familyid=83a52af2-f524-4ec5-9155-717cbe5d25ed&displaylang=en

Windows Mobile 5.0 SDK for Smart Phone

http://www.microsoft.com/downloads/details.aspx?familyid=dc6c00cb-738a-4b97-8910-5cd29ab5f8d9&displaylang=en

Windows CE 5.0

http://msdn2.microsoft.com/en-us/embedded/aa731407.aspx

.NET Compact Framework learning tutorials,documents,sample applications for developers get from here.

http://msdn.microsoft.com/netframework/programming/netcf/default.aspx

http://msdn.microsoft.com/netframework/programming/netcf/netcfsamples/default.aspx

http://samples.gotdotnet.com/quickstart/CompactFramework/

http://msdn2.microsoft.com/en-us/library/sa69he4t.aspx

http://msdn2.microsoft.com/en-us/library/f44bbwa1.aspx

2 thoughts on “.NET Compact Framework 2.0

  1. Hi,

    is it possible to grab the output of the webbrowser control and use that as an image (so basically screen grab it)?

    Kind regards,

    Bas

Leave a reply to blogs Cancel reply