1 / 44

Compact Framework .NETcf : from the trenches

Compact Framework .NETcf : from the trenches. casey chesnut brains-N-brawn.com 12/13/2004. Questions. Language C#, VB .NET, C++, Java At work .NET, .NETcf Windows CE Questions are encouraged throughout the presentation. Experience. Pervasive / Seamless Computing

Sophia
Download Presentation

Compact Framework .NETcf : from the trenches

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Compact Framework.NETcf : from the trenches casey chesnut brains-N-brawn.com 12/13/2004

  2. Questions • Language • C#, VB .NET, C++, Java • At work • .NET, .NETcf • Windows CE • Questions are encouraged throughout the presentation

  3. Experience • Pervasive / Seamless Computing • Web Services (ASMX, WSE) • Mobility (CF, Tablet) • Speech (Speech .NET, SAPI) • Location Based Services (MapPoint, GPS) • Security • Artificial Intelligence

  4. 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 • Client-side WSE 2.0 and WS-* • Barcode Image Reader • Custom Speech Recognition • Custom Text-To-Speech

  5. Agenda • [ Platform Ahead CF Chapter ] • [ /cfWSE article(s)? ] • What is missing • How to get it back • Where we are now • Futures • Resources

  6. What Is Missing • Assemblies • Namespaces • Types • Events • Properties • Methods • Overloads • Behavior

  7. .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

  8. Metrics * Beta 1 Numbers for all assemblies

  9. Examples • Typed DataSets (.xsd) • Resource files (.resx) • Hardcoded strings • Registry keys • Environment variables • File paths • Types • Sealed • Partial implementations • Controls

  10. Examples • pInvoke • Unicode • MarshalAs • FieldOffset • Missing or different DLLs • Missing or different OS features • WMI • Hosts • Updating controls from thread • Bugs

  11. How To Get It Back • Open source efforts • 3rd party controls • OS • pInvoke CE .NET Win32 APIs • eVC++ thunk layer • Write the logic yourself

  12. Open Source • OpenNETCF.org • Smart Device Framework v1.2 July 15, 2004 • Pocket PC Magazine Award Winner • Complementary to .NETcf • Adds missing functionality that desktop has • Adds functionality specific to devices • e.g. 15 controls with designer support • Visual Studio .NET Integration • Be aware of license

  13. Open Source • go-mono.org • “Effort to create an open source implementation of .NET” • Not intended for CE • Platform independence is slow • Be aware of licensing • ssCli / Rotor • MS initiative • Academic licensing only • Port to CE .NET underway

  14. 3rd party controls • Franson GpsTools • /n Software’s IP*Works for CF • Field Software PrinterCE.NetCF • Odyssey CfCom • InstallShield Developer Mobile Edition • Preemptive Dotfuscator • ComponentOne Studio for CF • Xceed Zip for .NETcf • IntelliProg UI controls • HP thumbprint biometric

  15. OS (pInvoke) • VB .NET cannot 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

  16. OS (pInvoke) • coredll.dll has 1600 functions • Cannot handle nested structures • Flatten into byte arrays • Manually marshal • Managed pointers • DLLImport CE & XP pattern for keeping common codebase • Native thunking layers • e.g. CF -> eVC++ -> COM

  17. Write it yourself

  18. .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

  19. Where We Are Now

  20. Development • .NETcf support in VS.NET • Supplement with eVC++ tools • Can do command line builds • Ports of nUnit to run on a device • Use ethernet for debugging • Class Library Comparison Tool • Windows Mobile Developer Power Toys

  21. Emulator • Same image as run on device • 80% speed of device • Newer emulators can do GAPI • eVC++ can share folders • Can sometimes active sync • Cannot listen • Ultimately need a slew of devices

  22. 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

  23. Debugging (pInvoke) • Cross platform pInvoke signatures • SetLastError, Marshal.GetLastWin32Error • Exceptions • NotSupportedException • MissingMethodException • Look at .h files • dumpbin /exports (name mangling) • P/Invoke Wizard, pInvoke.net

  24. Data • Web Services • SQL CE • XML • DB API • Pocket Access • CSV • 3rd party

  25. SQL CE • Connected – Sql Server • Disconnected – SQL CE • Merge Replication • No concurrent access • Basic SQL support • No stored procedures • Runs in process • Can become corrupted

  26. Communication • Web Services • Sockets • System.IRDA • OpenNetCF Phone • OpenNetCF Bluetooth • OpenNetCF Wi-Fi • NO Remoting

  27. 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

  28. Performance • Tech Preview was interpreted • Machine code is generated (but not much) • 2 JITs (ARM & other), No NGEN • ARM is supposed to be twice as fast • UI is ~20% slower on device • Release builds are slower? • No profiling tools • Environment.TickCount • QueryPerformanceCounter • SP2 has some significant resource and xml handling speed ups

  29. What is slow • XmlDocument • Reflection • Catching Exceptions • pInvoke • DataSets • Web Services • Data Binding

  30. What is faster • XmlDocument – XmlTextReader / Writer • Reflection – pre generate code • Catching Exceptions – only exceptions • pInvoke – wrap into native thunk layer • DataSets – SQL CE • Web Services – call from a thread • Data Binding – bind manually

  31. What is faster • SQL CE replication • Pre-init behind the scenes • Re-use objects • StringBuilder • Drawing controls top-down, parents 1st • Don’t overdesign

  32. Final Thought • Stages of a Mobile Developer • I can’t do anything! • Nevermind, everything I need is here, I just need to do some work to access it. • Why is this so slow? • Maybe I should optimize my code … • Remember that these are resource constrained Devices! • Remember that these are resource constrained Devices!

  33. Futures • Smartphones • CF v2.0 • SQL Mobile • Future Windows Mobile Platform • To watch • Predictions

  34. SmartPhone • 2002 OS does NOT support .NETcf • No future support announced by MS • 2003 Windows Mobile • 2nd edition release happening in US • will run CF v1 but not CF v2 (PPC will) • .NETcf is basically unchanged • Missing some UI controls • Missing SQL Server CE • 1-hand usage / no touch screen

  35. CF v2.0 • eVC IDE integrated into VS .NET • Mixed native and managed debugging • Remote tools • Attach to running process • Language updates • Generics, Iterators, Anonymous methods • Performance • Execution engine, Unified JIT, profiling(?) • Interop • COM RCW, Marshalling, Runtime hosting(?)

  36. CF v2.0 • 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

  37. CF v2.0 • Emulator • ActiveSync, Shared Folder, Stateful, Orientations • Protocols • IPv6, Kerberos, NTLM, SOAP 1.2 • XML • XPath(?), Schemas, Serialization • BCL • Image, Messaging, Registry, Cryptography, Serial, Sound

  38. SQL Mobile • Multiple Connections • Improved Performance • Greatly Improved Tool Support • SqlCeResultSet • Bulk loads • Cursor • The desktop does not get this  • Runs on Tablet PCs too • Fixes 2.0 corruption bug

  39. Future Windows Mobile Platform • Enhanced services and device support • Mobile Outlook • SMS Messaging • Telephony • Notifications Broker • Location Services • Peripherals support • Device Configuration • Direct3D, DirectDraw • Distributed through SDKs

  40. To watch • Portable Media Center • Has .NETcf v1.0 on it (closed) • SPOT watches • 384K RAM, ~1 meg flash, 27Mhz • OS = HAL + CLR • Only what is needed • Interpreted • .netcpu • For .NET embedded platforms • New form factors • Motorola MPx • Mappoint Location Services • WS Device Profile (UPnP 2.0)

  41. Predictions • HREF EXEs (CAS?) • Car .NET • Longhorn • Modular

  42. Resources • Newsgroups (microsoft.public.) • dotnet.framework.compactframework • smartphone.developer • Portals • msdn.microsoft.com/smartclient/understanding/netcf/ • pocketpcdn.com • devbuzz.com • codeproject.com/netcf/ • microsoft.com/seminar/events/series/msdnmobility.mspx • brains-N-brawn.com/cfBCL/ • Spelunking • Reflector, ILDasm

  43. 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) C# & VB • Building Solutions with the .NETcf (Addison) VB • .NET Compact Framework Programming (Addison) C# or VB

  44. Questions

More Related