Introduction to the Compact Framework Marcus Perryman Principal Consultant Microsoft.

Slides:



Advertisements
Similar presentations
Unit 1: Overview of the Microsoft.NET Platform
Advertisements

.Net Compact Framework A Mostly Straight Path, but with Some Interesting Curves Richard Kucia Kucia Associates
Introduction to .NET Framework
Tahir Nawaz Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a.
Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
Platform Architecture Mike Zintel Development Manager.NET Compact Framework Microsoft Corporation.
SSCLI (Shared Source Common Language Infrastructure) (code name: Rotor)
Developing with the.NET Framework Rob Howard Program Manager.NET Framework Team Microsoft Corporation.
.NET Framework Overview Pingping Ma Nov 16 th, 2006.
.Net Compact Framework. Microsoft.Net is often referred as Plateform for web services But.net vision is more than web services – It talks about how people.
Introduction. What is.Net? The hype: “Microsoft.Net is a set of Microsoft software technologies for connecting information, people, systems, and devices.
.Net Overview Giuseppe Attardi Università di Pisa.
Introduction to the C# Programming Language for the VB Programmer.
Thursday Evening 6.30VB.NET Introduction 7.30Break for food 8.00VB.NET Migration 8.45Q & A 9.00Done.
Introducing the Common Language Runtime for.NET. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution.
Introducing the Common Language Runtime. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution engine.
SQL Server 2005 CLR Integration ADO.NET 2.0 Mike Taulty
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Developing International Applications for Mobile Devices with.NET Achim Ruopp International Program Manager Microsoft Corporation.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 18 Microsoft’s Approach 1 –.NET Mobile Framework Rob Pooley.
Using.NET Skills To Build Mobile Applications In Compact Framework Punit Shah Technical Lead | Microsoft |
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
Overview of Microsoft.Net and Vb.Net ITSE 2349 Spring 2002 Material from Microsoft.Net an Overview for ACC faculty by Stuart Laughton and Introduction.
June 2003 Beginning Compact Framework Mohammad Faridi (faridianslip) Umer Faruq.
Visual Studio.NET and.NET Compact Framework Application Development Mike D. Smith Group Program Manager Developer Division Microsoft Corporation.
Microsoft.NET Framework Overview Abidi Mahmoud Seminarium on Component -based Software Engineering.
Architecture of.NET Framework .NET Framework ٭ Microsoft.NET (pronounced “dot net”) is a software component that runs on the Windows operating.
.NET Overview. 2 Objectives Introduce.NET –overview –languages –libraries –development and execution model Examine simple C# program.
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
.NET Framework & C#.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Windows CE 시스템 개발 개요. 임베디드시스템소프트웨어 -Windows CE 2 Overview  Selecting a Windows Embedded Operating System  The Windows CE Platform Development Cycle.
Overview of System Development. Overview Selecting a Windows Embedded Operating System The Windows CE Platform Development Cycle The Application Development.
CS795/895: Introduction. Topics Distributed Systems –Availability –Performance –Web Services Security –Authentication –Authorization –Confidentiality.
Managed C++. Objectives Overview to Visual C++.NET Concepts and architecture Developing with Managed Extensions for C++ Use cases Managed C++, Visual.
What is.NET? CS 351 Ed Gellenbeck. Today What is.NET? What Problems Does.NET Solve? What are.NET Framework Components?
.NET Framework Danish Sami UG Lead.NetFoundry
.NET Compact Framework Performance Strategies MBL 402 Ivo Salmre Product Manager.NET Developer Technologies, UK Microsoft Corporation.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 17 Microsoft’s Approach 1 –.NET Mobile Framework Rob Pooley.
.Net – The First Glance What Is.Net, Why Use.Net.
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
Windows CE 시스템 개발 개요. 모바일운영체제 - Windows CE 2 Overview  Selecting a Windows Embedded Operating System  The Windows CE Platform Development Cycle  The.
MBL401.Net Compact Framework: Data Access Best Practices Paul Foster Mobile solutions architect.
Intro to dot Net Dr. John Abraham UTPA CSCI 3327.
.NET Mobile Application Development Messaging & Communication from Mobile Devices.
Key Components of.NET Framework  Common Language Runtime  CLR at Design time  CLR at Runtime  Class Library  Assemblies  Namespaces  ASP.NET  Applications.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
MBL490 Deploying Applications to Smartphone and Microsoft® Powered Pocket PC Marcus Perryman Consultant.
.NET Compact Framework Per Ahlberg. Agenda.NET CF vs.NET Framework Major Areas Base Classes Drawing/Forms Data/XML Web Services Application Development.
PerlNET: The Camel Talks.NET Jan Dubois The Perl Conference 6 San Diego, July 26 th 2002.
Object Oriented Software Development 4. C# data types, objects and references.
DEV394.NET Framework: Migrating To Managed Code Adam Nathan QA Lead Richard Lander Program Manager Microsoft Corporation.
.NET Mobile Application Development XML Web Services.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
Just-In-Time Compilation. Introduction Just-in-time compilation (JIT), also known as dynamic translation, is a method to improve the runtime performance.
Advanced Managed Code Development Features Marcus Perryman
Introduction to the Microsoft.NET Framework Chris Wastchak Student Ambassador to Microsoft.
Introducing the Microsoft® .NET Framework
An Introduction to the Shared Source Common Language Infrastructure (SSCLI) Damien Watkins Copyright Watkins 2002.
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Mobile Application Development 2005 By Sam Nasr July 25, 2006
.NET and .NET Core 2. .NET Runtimes Pan Wuming 2017.
CS360 Windows Programming
Introduction to C# AKEEL AHMED.
Windows Forms and Smart Device Extensions in the End-to-End Application Hans Verbeeck Developer Consultant Microsoft EMEA.
Overview of System Development for Windows CE.NET
IS 135 Business Programming
Developing Managed Code for Smartphone 2003
.NET Framework Design Goals
Presentation transcript:

Introduction to the Compact Framework Marcus Perryman Principal Consultant Microsoft

Agenda  Design goals  Key components  Common features with the desktop  Differences from the desktop  What’s in and out

What is Compact Framework Design Goals Target mobile and embedded devices  Portable subset of.NET Framework  No new ‘compact’ namespaces  Visual Basic.NET & C# compiler support in v1  Leverage Visual Studio.NET  Run managed.EXEs and.DLLs directly  Debug with Visual Studio.NET  Peacefully co-exist with host OS  Run on native threads, P/Invoke to call native code

Key Components Host Operating System Platform Adaptation Layer Applications.NET Compact Framework App Domain Host ManagedNative Platform Specific Class Libs Base Class Libs Execution Engine (MSCOREE.DLL) - CLR Smart Device Extensions

Compact CLR Common Features  Verifiable type safe execution  No uninitialized variables, unsafe casts, bad array indexing, bad pointer math  Garbage Collection  No ref-counting, no leaks  JIT compilation  Error handling with exceptions  Common type system  Call, inherit, and source-level debug across different languages

Compact CLR Differences  COM Interop  Good support for calling native DLLs  Support for calling a COM object through DLL wrappers  No support for writing a COM / ActiveX object in C# or Visual Basic  No Install-time JIT (nGen)  No Reflection Emit  No Remoting  Client web services is fully supported  No Generic Serialization  Datasets can be serialized to XML  Subsets of other areas of functionality

.NET Compact Framework System System.DataSystem.Xml System.Web Globalization Text Security Collections Resources Reflection Net IO Threading Diagnostics ServiceProcess Configuration Design ADO.NET SqlServerCe SqlClient Xslt/XPath XmlDocument Runtime InteropServices Remoting Serialization Serialization ConfigurationSessionState CachingSecurity Services Description Discovery Protocols UI HtmlControls WebControls System.Drawing Imaging Drawing2D Text Printing System.WinForms DesignComponentModel Reader/Writers

Supported Controls ButtonCheckBoxComboBoxContextMenuDataGridDomainUpDownFileOpenDialog  Supported controls HScrollBarImageListLabelListBoxListViewTreeViewFileSaveDialog MainMenuNumericUpDownPanelPictureBoxProgressBarRadioButton GroupBox Printing Controls RichTextBox NotificationBubble (PPC) StatusBarTabControlTextBoxTimerToolBarVScrollBar  Unsupported controls  Unsupported controls – not available in CE CheckedListBoxColorDialogErrorProvider HelpProviderLinkLabelNotifyIcon ToolTipSplitterFontDialog

Framework Size  Framework size (RAM or ROM)  ~1.5 MB  Running RAM needs  1 MB+ (depends on app)  Typical application sizes  KB  Apps often smaller due to use of platform features in the framework

DEMO Creating a basic form Consuming a web service

Advanced.NET Compact Framework Development

Agenda  Under the hood – what goes on with CF  JIT, GC and Pitching  Performance  The art of tuning  Platform Interop  Getting to native code  Marshalling  Callback’s  Summary

Under the hood

Architecture Host Operating System Platform Adaptation Layer Execution Engine (MSCOREE.DLL) Platform Specific Class Libs Base Class Libs Applications.NET Compact Framework App Domain Host … Launch ManagedNative

The EE A short review  Compiled managed code is a binary in Microsoft Intermediate Language  Code is just-in-time compiled to the native processor language on type-by-type, method-by- method basis  Resulting native code is cached for later reuse  Over the lifetime of the app, the up front cost of jitting is amortized, and becomes less and less significant

Under the Hood  Build process  Same compilers  Local exe produced – additional Deploy step  File format  Standard PE format with no native code  Module load upgraded on device  Contains Intermediate Language (IL) blocks  Resources bound in or deployed in parallel  Deploy  Uses Connection Manager not Platform Manager  Again over Active Sync

DEMO ILDASM Multiple environments

Active Sync Connection Manager Remote Deploy And Debug Visual Studio.NET Windows DebugManager Device or Emulator STREAM CONNECT Process Enumerate App.exe File Copy App.pdb App.exe Remote Exec STREAM CONNECT Remote Debug

Per-Thread Control Flow ExecuteManagedMethod JITCompiled? Verify & JIT CompileMethod Load Base Classes Locate “Main” Class Class Execute Native (Until next Method) Yes LoadContainingClass No OtherClasses? Load Other Class Yes -Parents -Containing called methods -Declaring Args, Locals, Fields -Allocated (new) Jump to Native Code Return to CLR

Garbage Collection Desktop: G 0G 1G 2 2k Mark Promote Mark Promote

Garbage Collection Compact Framework : 5K Threshold MarkCompact Pitch Code? LRU

Performance

What Is Performance?  Affected by two principles  Absolute Performance of the system; the raw processing horsepower  Apparent Performance of the application; affected by how the application is written Application performance is qualitatively measured by how responsive the application is to the end user

Code Pitching  Occurs when large volumes of allocated memory cause memory pressure  Runtime will discard or pitch code from the code cache  Qualitative inspection will tell you when this occurs

Behavior Under Memory Pressure Memory utilization Performance

Compact Framework Performance  User Interface:  Version 1 performance is excellent!  System.Drawing and System.Windows.Forms call to native APIs beneath  Call “batching” where possible  Pools and reuses Window Handles  Data And XML Performance  Version 1 performance is good  Mostly implemented in managed code  Memory pressure effect data perfomance

Performance Tuning  Analyze Performance of Application  Discover where the application is slow  Choose where to optimize  What’s important to the customer scenarios?  Understand The APIs  How abstract is the API?  Example: XmlDocument vs XmlTextReader/Writer  What work has to happen under the hood?  Be aware of how events fire  Keep responsiveness

Performance Tips and Tricks

Execution Engine  Don’t call GC.Collect()!  Minimize the number of function calls  Consider making functions larger rather than having incredibly deep call stacks  Make use of asynchronous calls where useful, but avoid creating too many threads  Reduce, reuse, recycle!  The less memory you allocate, the faster your app will be!

User Interface  Reduce number of method calls  Example use Control.Bounds instead of Control.Location + Control.Size  Create the Window tree top down, rather than bottom up  Opposite of what VS.NET does by default  Minimize control addition on Form.Load()  Defer loading of controls until they are used

Handling Data  Make asynchronous requests  Defer data loading until it is required, discard when data no longer in use  Minimize data in memory at any time  Forward only reading is always faster than in memory representations  XmlDocument versus XmlTextReader  DataReader versus DataAdapter  Use StringBuilder for complex string manipulations

Interop

Types Of Native Code Interop  Calling native DLLs from C# and VB.NET  DLL Interop with P/Invoke is supported  Some limitations  No support for COM Interop  Some COM support through P/Invoke and DLL wrappers  Exposing managed code objects as native DLLs, COM or ActiveX objects  Not supported

Overall Native Code Interop strategy  Focus on enabling versus exhaustive  PInvoke is powerful, but advanced or edge case scenarios are more difficult than the desktop  It is possible for COM and.NET components to peacefully coexist in the same process/thread  Focus on simplicity for Version 1.0  Native code interop is very fast and simple

Platform Invocation PInvoke  Allows users to call custom native code and Windows APIs  Declare statement in Visual Basic  DLLImport Attribute in C#  Very flexible  Good support on the device  Extensively used in Forms and other parts of the framework

Simple Example MessageBox int MessageBox( HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType ); [DllImport("coredll.dll")] private static extern int MessageBox( IntPtr hWnd, string lpText, string lpCaption, uint uType); Private Declare Function MessageBox Lib "coredll.dll" ( _ ByVal hwndOwner As IntPtr, _ ByVal hwndOwner As IntPtr, _ ByVal lpText As String, _ ByVal lpText As String, _ ByVal lpCaption As String, _ ByVal lpCaption As String, _ ByVal uType As Integer) As Integer ByVal uType As Integer) As Integer

MessageBox using System.Runtime.InteropServices; [DllImport("coredll.dll")] private static extern int MessageBox( IntPtr hWnd, string lpText, string lpCaption, uint uType); MessageBox(IntPtr.Zero, "Hello World!", "Interop1", 0); 1.Loads and initialises coredll.dll 2.Locates the entry point MessageBox 3.Calls into the unmanaged code 4.Completes and returns back to managed code

DEMO Calling MessageBox

Data Marshaling  Simple Types  Direct Translation  Simple Objects and ValueTypes  Objects that contain simple types  Execution engine points at the data of the object  Some exceptions  Complex Objects and Value Types  Objects containing other objects need to manually marshal data

Marshaling Of Simple Types  The execution engine marshaling of simple data types C# Visual Basic Native Code intInteger int (32-bit integer) shortShort short (16-bit) boolBoolean BYTE (8-bit)* charChar wchar (16-bit) StringString wchar * Array int [] Array Integer () Data of the Array int * longLong Not Supported (64-bit) doubleDouble Not Supported (floating point) *bool and Boolean DO NOT convert to a Win32 BOOL

Marshaling Simple Objects  Members of classes are always laid out sequentially  Only classes containing simple types will be automatically marshaled Native Code - C typedef struct _RECT { LONG left; LONG top; LONG right; LONG bottom; } RECT; C# public class Rect { int left; int top; int right; int bottom; }

Marshaling Complex Objects  Marshal class  Located in System.Runtime.InteropServices  Provides advanced functionality to customize marshaling  Allows you to get copy managed objects into native code  Allows you to read and write raw memory if needed

DEMO Make a phone call

Callbacks  No support for direct native to managed function calls  Use MessageWindow  Part of Microsoft.WindowsCE.Forms  Steps for Callback  Create a MessageWindow in Managed  Pass window handle to native  Native sends messages back with it  Managed code can trap window messages

DEMO Using MessageWindow

Summary  Performance:  Understand what is acceptable for data “freshness”  Think asynchronously for best UI performance  Design, test and iterate on your design considering multiple approaches  Reduce, reuse and recycle objects  Interop:  Native DLL entry points can be called  COM objects can be wrapped by std DLLs  ActiveX controls not supported (3 rd party solution)  C# and Visual Basic components cannot be exposed as COM components or ActiveX controls

Advanced.NET Compact Framework Development BRIEF: In this session we will examine some of the more advanced topics around.NET CF starting with a look under the hood at what Compact Framework actually does. We will consider some design approaches and coding techniques that can lead to higher performance of your application, explore how to call and be called by native code, see the flexibility in ADO.NET on the device and finish by looking at the packaging, deployment and installation options available.