Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Developer's Guide
Platform Invoke Support

Platform invoke is a service that enables managed code to call unmanaged functions implemented in DLLs. You can use platform invoke semantically in the same way as in the full .NET Framework, but the .NET Compact Framework has a few limitations in marshaling objects and types between unmanaged and managed code.

There are three parts to a .NET Compact Framework platform invoke:

  1. At design-time, the developer provides a description of the unmanaged function to call. This includes the module name (DLL file), entry point name, and calling convention.

  2. At just-in-time (JIT) compile time, the common language runtime extracts this information from the metadata, locates the DLL containing the function, loads the DLL into memory and retrieves the address of the function. If the module or function is not found, the common language runtime throw a MissingMethodException.

  3. At run time, the common language runtime marshals the parameters from managed format to unmanaged format before the unmanaged function is called. The common language runtime determines how to marshal each parameter based upon the managed declaration of the method.

DllImportAttribute Supported Fields

Lists the subset of fields supported for the DllImportAttribute class.

Platform Invoke Wrapper Example

Provides example code for providing a structure for making platform invoke calls.

Interop Marshaling Support

Discusses differences in the .NET Compact Framework for marshaling data types between managed and unmanaged code.

How to: Get the Device Platform, How to: Get the Device ID and Name, How to: Get or Set the System Time, How to: Get Device Memory, How to: Reset the Device, How to: Play Sounds, How to: Display a Gradient Fill, ,

How-To topics demonstrate using platform invoke

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker