Mobile Applications with the 'NET Compact Framework - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Mobile Applications with the 'NET Compact Framework

Description:

Reflection. Net. IO. Threading. Diagnostics. ServiceProcess ... No reflection emit. Cannot create native images (pre-JIT) No asynchronous delegates ... – PowerPoint PPT presentation

Number of Views:134
Avg rating:3.0/5.0
Slides: 29
Provided by: alexth
Category:

less

Transcript and Presenter's Notes

Title: Mobile Applications with the 'NET Compact Framework


1
Mobile Applications with the .NET Compact
Framework
  • Twice IT TrainingAlex Thissen

2
Agenda
  • Mobile applications
  • Smart Device Extensions
  • Whats new in
  • Visual Studio.NET 2003
  • Compact Framework
  • Data options
  • XML Web Services
  • SQL Server CE 2.0

3
.NET Development Platform for Devices overview
Smart Device Extensions
Visual Studio .NET
.NET Framework
Server-side Web Apps
Client-sideRich Apps
Local Code
ASP.NET Web Pages
Mobile Web Browser
.NET CompactFramework
4
Why SDE instead of MIT?
  • MIT does not work offline
  • Web pages do not have powerful UI
  • SDE can use full power of processing
  • Leverage SQL Server CE for data storage

5
SDE features of VS.NET 2003
  • Essentially same experience as Desktop
  • New project templates (Windows CE en Pocket PC)
    voor VB.NET en C
  • Introduces non-graphical application
  • Only support for languages C and VB.NET
  • New Project properties and Device Options
  • Emulators for any device image
  • Pocket PC and Windows CE.NET 4.0 included
  • Remote on-device debugging
  • Samples and documentation

6
.NET Compact Framework
7
Compact Framework architecture
.NET Compact Framework CLR
Applications
App Domain Host
Execution Engine (MSCOREE.DLL)
Platform Adaptation Layer
Host Operating System
8
Whats the same?
  • Common Language Runtime
  • Garbage Collection
  • JIT compilation of MSIL
  • Type safety
  • Exception manager
  • Common Type System (any language)
  • Platform Invocation enables calls to CE Win32
    Native API
  • C has 100 language compatibility

9
Whats different?
  • COM Interopability not present
  • No support for writing a COM object
  • Write your own native wrapper classes and use
    P/Invoke to call wrapper
  • Only 25 of class libraries present (less classes
    and overloaded methods)
  • Only remoting option is client-side web services
  • No ASP.NET or .NET Remoting
  • No generic serialization

10
Whats different? (continued)
  • No reflection emit
  • Cannot create native images (pre-JIT)
  • No asynchronous delegates
  • Cant use or make ActiveX controls

11
Mobile applications
  • This session has focus on working with data
  • No attention to tools and utility apps
  • Device must be mobile, not just wireless take
    your data with you if necessary
  • Connection state possibilities
  • Permanent connection to network
  • Occasional connection (docked or wireless)
  • Switching from connected to not connected
    should be easy or transparent to user

12
Working with mobile data
  • Accessing remote data
  • Networking, ADO.NET Providers or XML Web Services
  • Accessing local data
  • ADO.NET DataSet or XML files
  • Caching local data when offline
  • SQL Server CE, ADO.NET persistence
  • Synchronization of data when online
  • ActiveSync, SQL Server CE Synchronization

13
Networking Support
  • Sockets
  • Synchronous and asynchronous
  • Multiple protocols
  • Streams
  • Built on top of sockets
  • Synchronous and asynchronous
  • HTTP request and response
  • Use stream model
  • Requires no user knowledge of HTTP

14
Infrared support
  • New classes for Infrared use
  • namespaces System.Net and .Sockets
  • IrDAClient, IrDADeviceInfo, IrDAEndPoint
  • Use client to connect to endpoint
  • Retrieve stream

15
Data Access options
Windows CE SQL CE .NET Compact Framework
DataSet
16
Using XML Web Services
  • Web Service client fully supported on device
  • Only Basic and Digest authentication
  • Use Secure Sockets Layer (SSL) for secure
    communication
  • All types of encoding
  • Just add Web Reference in VS.NET 2003
  • Generates regular SoapHttpClientProtocol wrapped
    proxy
  • Instantiate proxy and call methods

17
Supported XML Classes
  • XmlDocument
  • Parses all data in document to in-memory tree
  • Random access to any part of tree
  • Higher memory requirements, but offers more
    functionality
  • XmlTextReader/Writer
  • Forward-only reader and writer of XML data
  • Better performance, no in-memory caching
  • Low memory requirements even for large documents

18
ADO.NET Providers
  • Two providers come with .NET CF
  • SqlServerCE
  • SqlClient (no Windows Integrated Security)
  • Sql Server Client provider works just like for
    the desktop
  • Must have a permanent connection to backend
    server (not useful for offline support)
  • Subset of classes are available
  • Could write your own custom provider

19
SQL Server CE 2.0
  • On device mini SQL Server
  • Only one concurrent connection allowed
  • One file databases (.sdf files)
  • Comes with a Query Analyzer
  • Two main mechanisms to work with backend data
  • SQL CE Replication
  • SQL CE Remote Data Access (RDA)

20
SQL Server CE 2.0 (continued)
  • Install size approximately 800kB
  • Supported platforms
  • Windows CE 3.0 (Pocket PC 2000/2002, Handheld PC
    2000, Windows CE.NET 3.0/4.x)
  • No longer support for Windows CE 2.x (PalmPC and
    HandheldPC 2.x)
  • New from SQL CE 1.0
  • Parameter queries (only unnamed)
  • Better exception support (SqlCeException)
  • Configuration Wizard

21
SQL CE Storage Architecture
.NET CF / Managed Stack
Native/Unmanaged Stack
VS.NET (VB.NET, C)
ADO.NET
Ethernet
eVB 3.0
eVC 3.0/4.0
SQL Server CE Data Provider
SQL Server Client Data Provider
TDS
ADO CE v3.1
Well Connected
CLR / .NET CF
OLEDB CE
OLEDB / Replication API
802.11b, CDPD, GSM, CDMA, TDMA, etc.
SQL CE Edition v2.0
Data Provider
Client Agent Replication and RDA
IIS
Server Agent Replication and Remote Data Access
OLEDB
QP/Cursor Engine/ES
HTTP
OLEDB
Storage EngineReplication Tracking
Occasionally Connected
22
SQL CE Replication
  • Use SQL Server 2000 to create a publication of
    data for subscribers
  • Conflict resolution
  • Smart updates with delta changes in both
    directions
  • Replicate data to device
  • Subscriptions can be copied for easy deployment
    onto many devices
  • Must use Merge replication
  • SqlCeReplication managed class
  • Add subscription of device to backend server
  • Synchronize method brings downs entire database
    schema (indexes and relations) on first sync and
    changes on subsequent syncs

23
Remote Data Access
  • Gives more direct access to backend server
  • Server can be SQL Server 6.5 SP5 or higher
  • Push and pull for every table
  • Code your own relational integrity into database
  • SqlCeRemoteDataAccess managed object
  • Three methodsPush, Pull and SubmitSql

24
RDA Pull
  • Pull method gets a single table from backend SQL
    Server
  • Must delete existing table before pull
  • Use SqlCeCommand to access SQL Server CE
  • SELECT COUNT() FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_NAMEOrders
  • DROP TABLE Orders
  • Must delete existing table before pull
  • Specify whether to use batching or not
  • No server configuration required

25
RDA Push
  • Use Push to update backend server with data from
    SQL CE database
  • Error table is used to store update errors during
    Push
  • No concurrency conflict detection!
  • Error table has a row for each error
  • Examine errors from table and resolve conflicts
  • Baching option
  • On all updates must succeed
  • Off row-level conflict detection

26
RDA SubmitSQL
  • Run SQL statements directly on database server
  • SQL statement cannot return rows
  • All action occurs on backend server
  • No local connection is needed

27
Debugging
  • Emulator is faster than device
  • Device may have proprietary hardware
  • Leave emulator open for faster startup
  • Avoid Smart Minimize of PocketPC
  • if DEBUG this.MinimizeBox falseendif
  • Do not use Debug.Write for PocketPC
  • Install loopback adapter for connectivity

28
Deployment
  • Easily deploy applications with CAB files
  • Installs into Program Files directory
  • Use .inf file to specify
  • Directories, files, settings and configurations
  • Can be found in obj folder of project
  • Create customized versions under a different name
    and change BuildCab.bat
  • Optional Setup.dll to further control setup
    process

29
Resources
  • Links
  • http//www.microsoft.com/sql/CE/default.asp
  • MSDN Library .NET Compact Framework
  • MSDN Library Pocket PC and SmartPhone
  • Books
  • Microsoft .NET Compact Framework (Core Reference)
  • The Definitive Guide to the .NET Compact
    Framework Not yet released

30
Summary
  • Compact Framework is subset of real .NET
    Framework
  • Smart Device Extensions make programming
    essentially same as desktop
  • Inherent differences for mobile app as opposed to
    desktop apps
  • Loads of data access options

31
Questions and Answers
  • ? ? ?
Write a Comment
User Comments (0)
About PowerShow.com