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
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
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
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
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
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
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
Reflection
Remoting
Secure Messaging
The .NET Compact Framework does not support client-side certificates and authentication using HTTPS. Use Basic authentication.
Security
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
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
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