1 / 22

Sharing assets between the .NET Compact Framework and the .NET Framework

Sharing assets between the .NET Compact Framework and the .NET Framework. Chris Tacke OpenNETCF Consulting www.OpenNETCF.com ctacke@opennetcf.com. FAQ. “I want to run the .net compact framework on the desktop. How to?”

gordon
Download Presentation

Sharing assets between the .NET Compact Framework and the .NET Framework

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. Sharing assets between the .NET Compact Framework and the.NET Framework Chris Tacke OpenNETCF Consulting www.OpenNETCF.com ctacke@opennetcf.com

  2. FAQ • “I want to run the .net compact framework on the desktop. How to?” • “I tried to use my own desktop dll on my PocketPC and it didn’t work. Help!”

  3. Why do I care? • Enlarge your market • Kick-start projects by leveraging existing biz logic • Get an edge over competitors • Impress your manager! • Same principles for cross-device code • Use PC tools against your code to improve netcf development

  4. Agenda • Set the scene • Why? • Differences • .NET • Visual Studio, Language, Framework, CLR • Platform • Windows Mobile vs Windows XP • Share code • 1 failure and 2 successes • Gotchas, tips and tricks • Code it, stub it, catch it, test it

  5. Visual Studio for Devices • Visual Studio 2005 Standard • Nothing additional in “Higher” versions • Resx format • Form factors • Emulator • Debugging • Remote tools • Change Target Platform • Targets both v1 and v2

  6. C#, VB – no other languages • Everything from a language perspective is there. No limitations • With CF v1.0, volatile keyword was not supported • …but everything is volatile anyway on CF • VB’s language includes support libraries • No Microsoft.VisualBasic.Compatibility • Compactness on main VB lib as with other Fx ones • No late binding • IL statements not supported • calli, localloc

  7. “Framework Compactness” • No ngen • No ASP.NET server • No Remoting • No runtime hosting • No code access security • No binary serialization, no Reflection.Emit • No codedom, no configuration • Trimmed namespaces (XSLT), classes (Button.Image), method overloads etc

  8. CF-specific classes v1.0 • Microsoft.WindowsCE.Forms • InputPanel, MessageWindow/Message • System.Net.IrDA • IrDAXXX • EndPoint, Client, DeviceInfo, Listener • System.Data.SqlServerCE • SqlCeXXXX • Command, CommandBuilder, Connection, DataAdapter, DataReader, Engine, Error, ErrorCollection, Exception, Parameter, RemoteDataAccess, Replication, Transaction

  9. CF-specific classes v2.0 • Microsoft.WindowsCE.Forms • HardwareButton • MobileDevice.Hibernate • SystemSettings.ScreenOrientation • DocumentList • Notification • LogFont • Microsoft.WindowsMobile.DirectX • .Direct3D • SqlCeResultSet

  10. Windows Mobile 5.0 • Has its own additional classes • Part of the platform • Not part of NETCF • Can be used by both CF v1.0 and CF v2.0 • Microsoft.WindowsMobile • .PocketOutlook • .Configuration • .Status • .Telephony • .Forms

  11. CF CLR • Garbage Collector • Mark and sweep (not generational) • 3 phases: Simple, Compact, Full • Triggered by • Allocation failure • App goes to background • 750KB allocation in v1.0 (1MB in v2.0) • JIT (iJIT & sJIT) • No ngen, Pitching, 64KB limit

  12. PPC vs desktop • Input Methods • Form/Dialog size • Navigation Between applications • App/Form Closing • Take Over the Device – don’t! • File System • Memory Constraint (resource constraint) • Deployment

  13. Is common UI a good idea? • Is non-UI code affected by these? • Input Methods • Form/Dialog size • Navigation Between applications • App/Form Closing • Take Over the Device – don’t! • Even if you can do it, should you? • Different UI guidelines on each platform • Least common denominator

  14. “Thank you for the background… …now tell me how to do it!”

  15. Full Fx assemblies on device • TypeLoadException • MissingMethodException • Different PKT • 969DB8053D3322AC (device) • B77A5C561934E089 (desktop) • “I insist that there are no desktop assemblies in my CF package/solution” • Use the loader log • Use VS2005 output window (build)

  16. CF assemblies on PC • Retargetable • CF binaries can be executed on PC • Not the other way round, as we saw • Runtime conditional paths • System.Environment.OSVersion.Platform • CF-specific assemblies will bomb • TypeLoadException • FileLoadException

  17. Share the code, not the binary • Compilation Constant • Two projects, two outputs, one set of code files • Build platform-specific binaries from same source

  18. Gotchas, tips and tricks • Solution/project setup • Stub it • E.g. InputPanel, Serializable • Partial Classes • WinForms, Other code • Runtime differences • PInvoke • Class Designer • Code it • SDF from OpenNETCF is a great example

  19. OpenNETCF:SDF v2.0 Full Fx classes • .ComponentModel. • BackgroundWorker • Licens* • .Win32.SafeHandles.* • .Configuration.* • .Net. • Ftp.* • NetworkInformation.* • .Diagnostics. • Stopwatch • FileVersionInfo • EventLog • .IO. • DriveInfo • FileSystemWatcher • .Runtime.InteropServices • SafeHandle • .Threading. • EventWaitHandle • Semaphore • .Drawing.ColorTranslator • .Windows.Forms. • GroupBox • IMessageFilter • NotifyIcon • SendKeys • PowerStatus • .Media.SoundPlayer

  20. How VS2005 & CF v2.0 improved the Everett story • Common Resx file format • Predefined constants • Docking and anchoring • Fx compatibility • Partial types • Data access code simpler • Deploy to MyComputer • Enable TODO

  21. Conclusion • Create desktop versions of your assemblies • Use conditional compilation • If commercial, change the UI to be platform-specific • Architect your product to that effect

  22. Questions? • Thank You!

More Related