410 likes | 545 Views
Compact Framework .NETcf : from the trenches. casey chesnut brains-N-brawn.com 12/15/2003 Harvard for David Platt’s .NET class. Questions. Language C#, VB .NET, C++, Java At work .NET, .NETcf CE. Experience. Web Services Compact Framework Tablet PC Speech .NET. Compact Framework.
E N D
Compact Framework.NETcf : from the trenches casey chesnut brains-N-brawn.com 12/15/2003 Harvard for David Platt’s .NET class
Questions • Language • C#, VB .NET, C++, Java • At work • .NET, .NETcf • CE
Experience • Web Services • Compact Framework • Tablet PC • Speech .NET
Compact Framework • Mappoint .NET Client • LBS – GPS, MapPoint, SQL NS, MSN Mess. • Signature Biometric • Speech Recognition – DIME & SAPI WS • Managed DirectPlay Wrapper for PPC • ASP.NET-like Web Service server • Port of a 75K –> 100K line WS app • ~20 web services, ~175 web methods • Cryptography and Client-side WSE
Agenda • [ Keith Pleas Intro. ] • [ SmartPhone and WSE article? ] • What is missing • How to get it back • Where we are now • Futures • Resources
What Is Missing • Assemblies • Namespaces • Types • Events • Properties • Methods • Overloads • Behavior
.NETfx versus .NETcf System.Web System.WinForms Services UI Design ComponentModel Description HtmlControls Discovery WebControls System.Drawing Protocols Caching Security Drawing2D Printing Text Configuration SessionState Imaging System.Data System.Xml ADO.NET SqlClient XmlDocument Serialization Reader/Writers Design SqlServerCe Xslt/XPath System Collections IO Configuration Runtime InteropServices * Security Net ServiceProcess Remoting Text Reflection * Diagnostics Serialization Globalization Resources * Threading
.NETfx Types: 4,753 Methods: 80,277 .NETcf Types: 1,360 Methods: 18,701 Metrics * mscorlib, system, system.data, system.drawing, system.windows.forms, system.xml * .NETcf adds SqlCe and IRDA namespaces
Examples • Typed DataSets (.xsd) • Resource files (.resx) • Hardcoded strings • Registry keys • Environment variables • File paths • Types • Sealed • Partial implementations
Examples • pInvoke • Unicode • MarshalAs • FieldOffset • Missing or different DLLs • Missing or different OS features • WMI • Hosts • Updating controls from thread • Bugs
How To Get It Back • Open source efforts • 3rd party controls • pInvoke • CE .NET Win32 APIs • eVC++ thunk layer • Write the logic yourself
Open Source • go-mono.org • “Effort to create an open source implementation of the .NET Development Framework” • Not intended for CE • Be aware of licensing • ssCli / Rotor • MS initiative • Academic licensing only • Port to CE .NET underway
OpenNetCF.org • Smart Device Framework (~January 2004) • Audio recording and playback, serial communication, registry and clock manipulation, notifications, environment setting, extended marshaler • 10 controls with designer support: Button, CheckBox, GroupBox, ColorDialog, LinkLabel, StatusBar, owner-drawn ListBox and SignatureCapture control
3rd party controls • Odyssey CfCom • InstallShield Developer Mobile Edition • Preemptive Dotfuscator • /n Software’s IP*Works for CF • ComponentOne Studio for Mobile Devices • Xceed Zip for .NETcf • IntelliProg UI controls • HP thumbprint biometric
pInvoke • VB .NET cant do unsafe • Call C# library if necessary • Only 32-bit blittable types • Pass by ref • Strings • unicode only, use StringBuilder • No callbacks from native code • MessageWindow • Make blocking call into native code
pInvoke • coredll.dll has 1600 functions • Cant handle nested structures • Flatten into byte arrays • Manually marshal • Managed pointers • DLLImport CE & XP pattern for keeping common codebase • Native thunking layers
.NETcf extended System.Web System.WinForms Services UI Design ComponentModel Description HtmlControls Discovery WebControls System.Drawing Protocols Caching Security Drawing2D Printing Text Configuration SessionState Imaging System.Data System.Xml ADO.NET SqlClient XmlDocument Serialization Reader/Writers Design SqlServerCe Xslt/XPath System Collections IO Configuration Runtime InteropServices * Security Net ServiceProcess Remoting Text Reflection * Diagnostics Serialization Globalization Resources * Threading
Development • Use eVC++ tools with device • Can do command line builds • Ports of nUnit • Get ethernet to device • VS.NET supported by .NETcf line • Class Library Comparison Tool • Windows Mobile Developer Power Toys
Emulator • Same image as run on device • 80% speed of device • Newer ones can do GAPI • eVC++ can share folders • Can sometimes active sync • Cannot listen • Ultimately need a slew of devices
Debugging • System.SR.dll • OutputDebugString • No console • TraceListeners • No event log (to file) • Use the device • Cannot attach to process • Cannot skip to next statement • Cannot do mixed native and managed • Native threads will not break
pInvoke Debugging • Cross platform pInvoke signatures • SetLastError, Marshal.GetLastWin32Error • Exceptions • NotSupportedException • MissingMethodException • Look at .h files • dumpbin /exports (name mangling) • P/Invoke Wizard
Data • Web Services • XML • DB API • Pocket Access • CSV • 3rd party • SQL
SQL • Connected – Sql Server • Disconnected – SQL CE • Replication • No concurrent access • No stored procedures • Basic SQL support • Runs in process • Can become corrupted
Garbage Collection • Not generational • Mark and sweep aggressive • Compacting is rare • Code pitching has never happened when i was watching • pInvoke memory leaks • Platform builder / cordbg • mscoree.stat
Performance • 2 JITS (ARM & other), No NGEN • ARM is supposed to be twice as fast • Machine code is generated, but not much • UI is ~20% slower on device • Tech preview was interpreted • Release builds are slower • No profiling tools • Environment.TickCount • QueryPerformanceCounter • SP2 has some significant resource and xml handling speed ups
What is slow • XmlDocument • Reflection • Catching Exceptions • pInvoke • DataSets • Web Services • Data Binding
Faster • SQL CE replication • Do not freeze the UI • Pre-init behind the scenes • Re-use objects • StringBuilder • Batch pInvoke calls in thunking layer • Use XmlTextReader / XmlTextWriter • Drawing controls top-down, parents 1st
Final Thought • Remember that these are Embedded Devices!
Futures • SmartPhone 2003 • Whidbey (.NETcf) • Predictions
SmartPhone 2003 • 2002 OS does NOT support .NETcf • No future support announced by MS • 2002 release just now happening in US • No upgrade path announced by carriers • 2003 release happening in Europe • .NETcf is basically unchanged • Missing some UI controls • Missing SQL Server CE
Whidbey • eVC IDE integrated into VS .NET • Mixed native and managed • Remote tools • Attach to running process • Language updates • Generics, Iterators, Anonymous methods • Performance • Execution engine, JIT, profiling • Interop • COM RCW, Marshalling, Runtime hosting
Whidbey • Emulator • ActiveSync, Shared Folder, Stateful, Orientations • WinForms • Docking, Anchoring, Tabbing, Auto-scroll, Clipboard, Extend existing types, Multi-resolution • Controls • WebBrowser, DateTimePicker, MonthCalendar, LinkLabel, Notification Balloon, DocList, RichInk, Splitter, DataContainer, UserControl, HelpProvider
Whidbey • Protocols • IPv6, Kerberos, NTLM, SOAP 1.2 • XML • XPath, Schemas, Serialization • SQL CE 3.0 • SqlCeResultSet • BCL • Image, Messaging, Registry, Cryptography • Serial, Sound
Whidbey • Direct3D, DirectDraw • Notifications of system state • POOM • Telephony • Device Configuration • Location Services
Predictions • HREF EXEs (CAS?) • SPOT • 384K RAM, ~1 meg flash, 27Mhz • OS = HAL + CLR • Only what is needed • Interpreted • Car .NET • Longhorn • Modular
Resources • Newsgroups (microsoft.public.) • dotnet.framework.compactframework • smartphone.developer • Source • OpenNetCF.org, go-mono.org, ssCli / Rotor • Spelunking • Reflector, Anakrino, ILDasm
Portals • microsoftdev.com • MS .NETcf FAQ • devbuzz.com • pocketpcdn.com • dotnetdn.com
Books • .NET Compact Framework (MS Press) C# • .NET Compact Framework Kick Start (Sams) C# & VB • Definitive Guide to the .NETcf (Apress) VB • SQL Server CE Database Development with .NETcf (APress) • Building Solutions with the .NETcf (Addison) • Programming the .NET Compact Framework (?) C# and VB.NET