380 likes | 522 Views
Silverlight 2 CoreCLR. Andrew Pardoe Program Manager CLR Execution Engine Andrew.Pardoe@microsoft.com. Why Silverlight?. Rich interactive applications Web deployment gives broad reach Windows, Mac OS X, Linux IE, Firefox, Safari, Konquerer Sandboxing provides security
E N D
Silverlight 2 CoreCLR Andrew Pardoe Program Manager CLR Execution Engine Andrew.Pardoe@microsoft.com
Why Silverlight? • Rich interactive applications • Web deployment gives broad reach • Windows, Mac OS X, Linux • IE, Firefox, Safari, Konquerer • Sandboxing provides security • Productive design and development • Reusable knowledge (XAML & .NET) • Best developer tools in the industry • Separate design and development
Non-Windows platforms • Mac OS X 10.4+ • Silverlight 1.0 supports all hardware • Silverlight 2 supports Intel Mac • Mac is fully supported by Microsoft • Major Linux distributions • Moonlight runtime implemented by Mono • Full cooperation of Microsoft • Access to documentation and tests • Legal covenant protecting Mono users
Silverlight security • Sandboxed applications • No user elevation or security prompts within the browser—just click a URL • Applications prevented from doing malicious things • Limited local interaction • Safe isolated storage • Client based file upload controls • Cross domain networking support
Code-behind • Silverlight “code-behind” model • Code lives behind the page • Updating the code doesn’t change the design • Productive design and development • Reusable knowledge (XAML & .NET) • Best developer tools in the industry • Separate design and development
Designers Designers and developers are different.
Developers Developers work from the inside outward.
What you need • Silverlight 2 Beta 1 • Notepad • No SDK required, everything is text • A better option… • Silverlight Tools for Visual Studio 2008 • Expression Blend 2.5 March Preview • Everything you need is online • http://www.silverlight.net
Why CoreCLR? • .NET is a desktop technology. Why use it on the web? • Developers, developers, developers! • Performance and expressiveness • Silverlight lets you use what you already know • C#, VB, JScript—Silverlight CoreCLR supports all .NET languages • SL2 DLR adds popular dynamic languages like IronPython and IronRuby
Why CoreCLR? • CoreCLR builds from same source code as the desktop CLR • 100% compatible execution environment • Much smaller package • 4.3 MB download for SL2 Beta 1 • What’s different in CoreCLR? • We’ll look at the desktop CLR and compare it to CoreCLR
Overview of Silverlight 2 Browser hosts through ActiveX Presentation Core CoreCLR UI Core JS Interop DLR Inputs, Controls,Media, DRM BCL
The CLR is simple, right? Write a program in .NET C# source Compile to MSIL executable Runs with Base Class Library MSIL + Metadata Running code loads the CLR EE Layout objects in memory Code + .NET JIT produces native code Managed protected environment VM & GC
What's different in CoreCLR? • Small size allows on-demand install • Fewer scenarios than desktop CLR • Sandboxed code • Smaller Base Class Library • Only hosted by ActiveX controls • Supported on Intel Apple Mac OS X
What's the same? • Dynamic Language Runtime • Execution engine • JIT compiler • Garbage collector • Virtual machine • New security model • Security Transparency replaces Code Access Security • Transparency may be supported in desktop
Program in any .NET language • Not just C# and VB (C++/CLI, F#) • Ada • Cobol • Eiffel • Forth • Fortran • Nemerle • Lisp • Perl • Pascal • many more
Dynamic Languages • DLR adds popular web languages • DLR creates MSIL at runtime • Built on a message-passing system • Objects respond to messages • Behavior based on language semantics • Messages converted to MSIL • Built on dynamic method dispatch and dynamic type system • Messages are bound to methods • Dynamic types are CLR types
demo DLRConsole
Local file system access • OpenFileDialogfor read-only local file system access • IsolatedStorageFile provides storage • Define the scope with a using directive • Exiting scope disposes file objects
Simplified Base Class Library • Web-hosting reduces scenarios • Click-time install reduces size • Simplified BCL is based on .NET CF • Non-generic collections removed • Localization culture information from OS • BackgroundWorkerfor most threading • See BCL team blog for more details • Guidance available to help port existing .NET code to Silverlight’s smaller BCL
Objects, versioning and binding • Versioning and binding are transparent • ActiveX host loads CoreCLR, creates appdomain and applies policies • Full access to XAML and HTML DOMs • XAML can be written dynamically • Javascript objects and DOM elements wrapped in managed wrappers
Appdomains and processes SL 1.0: XAML and Javascript SL 2 with shared CoreCLR SL 2 app in separate browser Another SL2 app shares same CoreCLR Different browser gets new CoreCLR Browser tabs share a single CoreCLR
Which CLR runs my code? • You need a CLR to run managed code • Could use the CLR on Windows… • …but changing code changes behavior • CoreCLR runs in-process with CLR • Managed browsers can host SL • Multiple CoreCLRs in-process • 100% Silverlight compatibility no matter what CLR is already on your machine
demo CoreCLRand CLRside-by-side
Native code generation • Same JIT on Mac and Windows • No NGen in Silverlight 2
Intel Mac support • CoreCLR runs on Mac OS X 10.4+ • Only supported on Intel Macs CoreCLR, Base Class Libraries and other platform assemblies Mac OS X 10.4+(Intel) Platform Adaptation Layer Windows(32-bit)
Execution engine is the same • Same execution engine as CLR • Core functionality: JIT, GC • Virtual machine: EH, threading • Simplified security model • CAS is gone! • Transparent, Safe Critical and Critical • All user code is transparent
Security Transparency Model • No more evidence, permissions, policy levels or code groups • No more complicated documentation • No more stackwalks for code access - • Transparent code can call public methods, use public types and override methods… • If it’s platform or same application’s code • If it’s Safe Critical or Transparent security
Security Transparency example WINAPI CreateFile (Critical code) creates file without any validation User code (transparent) wants to write a file System.IO.IsolatedStorageFileStreamWriter(SafeCritical code) verifies the request and calls Windows API
Silverlight is simple, right? Use same .NET skills C# source DLR adds new languages Web has simpler scenarios MSIL + Metadata Code uses smaller BCL Same CoreCLR on any host Code + .NET Security Transparency is easy Same CLR means no surprises VM & GC
demo Woodgrove Financial
demo Chess: Javascript vs. CoreCLR
Q&A Questions?
Shawn Farkas’ blog on CLR security http://blogs.msdn.com/shawnfa BCL team bloghttp://blogs.msdn.com/bclteam Silverlight – Get Started http://silverlight.net/GetStarted Where to find these slides http://blogs.msdn.com/apardoe Resources