Share via


Differences with the .NET Framework 

The .NET Compact Framework is a subset of the full .NET Framework. It implements approximately 30 percent of the full .NET Framework class library and also contains features and classes specific to mobile and embedded development.

This topic is not comprehensive of all differences between the frameworks, but lists the important differences needed for developing applications. The following table lists the areas of differences described in this topic.

Application domains

Disposed objects

Remoting

Arrays

Encoding and localization

Secure messaging

ASP.NET

Events

Security

Assemblies and file formats

Exception description strings

Serialization

Assemblies and global assembly cache

File names and paths

Size

Classes and types

High resolution

Sockets

COM interop

Input/Output (I/O)

String manipulations, regular expressions

Common language runtime

Installation and CAB files

Threads

Controls

Languages

Time intervals

Current directory

Math

Timers

Data

Memory

Visual Basic My

Data types and floating-point precision

Networking

Web services

Debugging at the command prompt

Performance testing

XML

Deploying applications

Proxy code

Diagnostics tracing

Reflection

Application Domains

The .NET Compact Framework does not currently support loading assemblies into a domain-neutral code area for use by multiple Application Domains in the .NET Compact Framework.

Arrays

Although some languages support lower bounds other than zero, the common language runtime does not and throws a MissingMethodException if the first element is other than zero.

ASP.NET

The .NET Compact Framework is primarily a rich client platform and does not provide ASP.NET support. To develop Web pages for mobile devices, you can use ASP.NET mobile Web controls. To develop Web pages for personal computers or Web service providers, see your ASP.NET documentation.

Assemblies and File Formats

Applications for both Frameworks use assemblies. Both Frameworks access portable executable (PE) files, which contain the Microsoft intermediate language (MSIL) and metadata that define a .NET Framework application. A PE file can refer to a programming namespace defined and shared by other assembly files.

See Binary Compatibilities with the full .NET Framework for more information.

Assemblies and Global Assembly Cache

The .NET Compact Framework does not currently support multi-module assemblies but does support satellite assemblies.

Classes and Types

The .NET Compact Framework supports a subset of the .NET Framework class library. This subset is appropriate for applications designed to run on resource-constrained devices and is semantically compatible with same-named classes in the .NET Framework.

For information about determining .NET Compact Framework support, see How to: Use the Class Library for the .NET Compact Framework.

COM Interop

The .NET Compact Framework supports COM interop in version 2.0. There are also enhanced marshaling capabilities. For more information, see Interoperability in the .NET Compact Framework.

Common Language Runtime

The common language runtimes in both Frameworks benefit from managed code execution, just-in-time (JIT) code compilation, and garbage collection. They support the Common Language Specification (CLS).

Both Frameworks have built-in primitive types as well as other types that you can use and derive from when building your application.

The common language runtime for the .NET Compact Framework is approximately 12 percent the size of the full .NET Framework common language runtime.

Controls

The .NET Compact Framework supports most of the Windows Forms controls in the full .NET Framework and contains controls specific to .NET Compact Framework.

Windows Forms controls are specially built for the .NET Compact Framework. For more information see Controls in the .NET Compact Framework.

Current Directory

The functionality of a current directory is not present in the Windows CE operating system, so the .NET Compact Framework does not support the GetCurrentDirectory and SetCurrentDirectory methods.

The .NET Compact Framework supports the WorkingDirectory property for a ProcessStartInfo. However, its context is not preserved by the running executable in subsequent launches and file loads.

Data

The .NET Compact Framework provides a subset implementation of ADO.NET and includes the SQL Server Mobile data provider. The System.Data.OleDb namespace is not supported.

For more information about data support, see Data Access and XML Support

Data Types and Floating-Point Precision

The .NET Compact Framework does not support the MidpointRounding enumeration.

In a division calculation, if the divisor is very large or at the maximum or very low or at the minimum floating point value, the calculation returns zero instead of the correct calculation.

The MIPS platform does not support the full precision specified by the Standard for Binary Floating Point Arithmetic specification, and can cause unpredictable results. Because of performance considerations, the .NET Compact Framework does not provide a floating-point emulation capability for this platform.

Debugging at the Command Prompt

The .NET Compact Framework does not support the new .NET Framework Command-Line Debugger (MDbg.exe) provided by the .NET Framework version 2.0. The older CLR Debugger (DbgCLR.exe) is deprecated in version 2.0 of both Frameworks.

Deploying Applications

Deploying is as easy as copying the assembly to the target device by using a cable from the desktop computer or its infrared port or by a wireless Internet or intranet connection. In Microsoft Visual Studio 2005, you can deploy directly to the device while debugging.

Diagnostics Tracing

The .NET Compact Framework does not support configuration files for tracing, but you can use performance counters. For more information see Performance and Diagnostics.

Disposed Objects

The full .NET Framework does not guarantee that accessing properties or methods on a disposed object always succeeds. However, accessing some properties such as Text often does succeed on the .NET Framework. Due to implementation differences between the .NET Framework and .NET Compact Framework, accessing methods or properties on a disposed object will almost always fail on the .NET Compact Framework.

Encoding and Localization

Localization, or globalization, support, such as date formatting and sort tables appropriate for the locale, defers to the underlying operating system whenever possible for compatibility and size efficiency.

The .NET Compact Framework depends on the operating system for sorting data, so the sort results may be unexpected for some cultures.

The .NET Compact Framework does not support per-thread CurrentUICulture settings.

For more information about globalization support, see Encoding and Localization in the .NET Compact Framework.

Events

The .NET Compact Framework supports the GotFocus and LostFocus events, but does not support the Activated and Deactivated events.

Exception Description Strings

The .NET Compact Framework provides exception error message strings in a separate DLL, System.SR.DLL, to save memory.

You can also provide exception strings for other cultures to localize applications.

File Names and Paths

Windows CE resolves a file name specified without path information as being in the root directory of the device, not in the application directory.

To ensure successful operations, specify absolute path information.

The .NET Compact Framework processes URI strings prefixed by the file:// scheme differently from the full .NET Framework. A relative file://myfile specification resolves as \\myfile. Using file:///myfile (three slashes) resolves as \myfile in the root directory.

You can get the version of an assembly with Version, but its support is dependant on the manufacturer of the device is cannot be guaranteed.

To get the name of the directory containing an application, see How to: Get the Application Directory.

High Resolution

In the .NET Compact Framework version 2.0, DPI resolution is automatically handled in Visual Studio 2005 projects. For more information high resolution, see How to: Handle Orientation and Resolution Changes.

Input/Output (I/O)

Because of differences in device operating systems, there are constraints and restrictions on the I/O model. The .NET Compact Framework does not provide file change notifications.

Because device I/O occurs in RAM, file and directory attributes cannot be set or accessed.

Installation and CAB Files

You can use CAB files and create MSI applications to distribute your applications.

Languages

The .NET Compact Framework supports development using Visual Basic and Visual C#, but does not currently support C++.

Math

Not all Math methods are supported on all device platforms; however, they are included in the API for compatibility.

Memory

The .NET Compact Framework is optimized for battery-powered systems and avoids heavy use of RAM and CPU cycles. For more information about saving memory, see Device Memory Management and How to: Improve Performance.

Networking

The .NET Compact Framework provides Infrared Data Association (IrDA) classes for making infrared connections and Web listening classes for servicing HTTP requests to the device. These classes are available only in the .NET Compact Framework. For more information see Networking and Connectivity.

Performance Testing

The .NET Compact Framework does not support code profiling or the Perfmon.exe file in System Monitor. However, there are performance counters you can use. See

Performance and Diagnostics for more information.

Proxy Code

The .NET Compact Framework does not support all the code generated by the Web Services Description Language Tool (Wsdl.exe). To determine what code is not supported, see How to: Use a Proxy Generated by Wsdl.exe.

Reflection

The .NET Compact Framework does not support the System.Reflection.Emit namespace.

The .NET Compact Framework does not currently support the equality operator (==) when comparing reflection objects such as MethodInfo, FieldInfo, PropertyInfo, EventInfo, MemberInfo, MethodBase, ConstructorInfo, and ParameterInfo. As an alternative, see Implementing the Equals Method.

Remoting

The .NET Compact Framework does not support remoting. You can use Message Queuing in the .NET Compact Framework for alternative solutions.

Secure Messaging

The .NET Compact Framework does not support client-side certificates and authentication using HTTPS. Use Basic authentication.

Security

There are several important security differences and considerations described in Security in the .NET Compact Framework.

Serialization

Because of size and performance considerations, the .NET Compact Framework does not support binary serialization using BinaryFormatter or SOAP serialization using SoapFormatter.

There is, however, serialization support for transmitting object data using SOAP in XML Web services and serializing datasets to XML.

Size

The .NET Compact Framework is 8 percent the size of the full .NET Framework redistributable package. The size on disk is 50 percent smaller due to Windows CE file system compression.

Sockets

Not all socket options are supported. For more information, see Socket Programming.

String Manipulations, Regular Expressions

Applications that use regular expressions in the .NET Compact Framework are not binary compatible with applications that use regular expressions in the full .NET Framework, but they are source-code compatible.

Threads

There are up to four threads created by a .NET Compact Framework application:

  • A main application thread.

  • A thread used to control various period timers and time-outs that can be scheduled by the system or applications.

  • A thread used to track changes to the active TCP/IP interfaces (simulating the media sense behavior that is present on Windows XP but not Windows CE).

  • A thread that is used to run object finalizers. It is created when the first finalizable object is garbage collected.

For more information about threading support, see Threading in the .NET Compact Framework.

Time Intervals

The value returned from Now is specific only to seconds, not milliseconds. You can get a finer measurement by using the TickCount property.

Timers

The Start and Stop methods for a System.Timers.Timer are not supported, but you can start and stop timing by setting the Enabled property of a System.Windows.Forms.Timer to true or false.

Visual Basic My

The .NET Compact Framework supports the Visual Basic My feature (see Development with My), except for the following My objects:

  • My.Application

  • My.Computer

  • My.User

  • My.Settings

Web Services

The Web services client runs wsdl.exe generated assembles directly.

Do not use localhost to create a Web service on the device, because localhost refers to the device running the application, as in the device itself. Instead, you should use either the machine's name or its IP address.

XML

Because of size considerations, the .NET Compact Framework does not support XML schema validation. It does support the XML Document Object Model (DOM). For more information, see Data Access and XML Support.

See Also

Other Resources

Overview of the .NET Compact Framework