Upload
eadoin
View
98
Download
0
Embed Size (px)
DESCRIPTION
Silverlight 1.1 CoreCLR 内部揭秘. Andrew Pardoe Program Manager 微软公共语言运行时 [email protected]. demo. Silverlight 1.0. Why Silverlight?. Why are applications on the internet important? Rich, interactive internet applications WPF is a powerful and expressive - PowerPoint PPT Presentation
Citation preview
Silverlight 1.1 CoreCLR 内部揭秘
Andrew PardoeProgram Manager微软公共语言运行时[email protected]
Silverlight 1.0
DEMO
Why Silverlight?Why are applications on the internet important?Rich, interactive internet applicationsWPF is a powerful and expressive
Clear separation between graphics and business logicPowerful designer tools for graphics and code
Expression Blend integrates designers into projectSilverlight cross-platform on most browsersServe Silverlight applications from any web serverWMV is the best video format on the web
From XAML to Silverlight<Ellipse Width="104" Height="90" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="87" Canvas.Top="8"/><Ellipse Width="28" Height="28" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="69" Canvas.Top="8"/><Ellipse Width="28" Height="28" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="179" Canvas.Top="8"/><Ellipse Width="21" Height="13" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="108" Canvas.Top="36"/><Ellipse Width="21" Height="13" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="146" Canvas.Top="36"/><Ellipse Width="104" Height="49" Fill="#FFFFFFFF" Stroke="#FF000000" Canvas.Left="87" Canvas.Top="63"/><Path Width="65" Height="10.5" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" Canvas.Left="107.5" Canvas.Top="87.5”/>...
Why use a desktop technology for the web?Developers, developers, developers!
Performance, expressiveness and reuse of knowledge
Silverlight lets you use what you already knowC#, VB, JScript—Silverlight supports all .NET languagesPopular dynamic languages like IronPython and IronRuby
CoreCLR built from same source as desktop CLR100% compatible but much smaller install package
What’s different in CoreCLR? We’ll look at the desktop CLR and compare it to CoreCLR
Why CoreCLR?
Overview of Silverlight 1.1
SL 1.1 Canvas hosted in IE by ActiveX control.HTML DOM fully exposed to WPF/E and .NET.
Windows Presentation Foundation / Everywhere
Animation Vector Graphics
Video Playback
CoreCLR Execution Engine
Base Class Library
User Input
Dynamic Language Runtime
The CLR is simple, right?
MSIL + Metadata
Your code + .NET Framework
Write a program with any .NET languageC# source code
Your code uses the Base Class Library
Running the program loads the CLR in the process
Managed execution CLR manages execution in protected environment
Compile it to an MSIL executable
Class loader creates in-memory managed objects
JIT produces native x86 (or 64-bit) code
What's different in CoreCLR?Small size allows on-demand installNew languages in Dynamic Language Runtime Fewer scenarios than desktop CLR
Sandboxed code can’t access system resourcesBase Class Library is targeted for the webOnly hosted by ActiveX controls
Supported on Intel Apple Mac OS XExecution engine is the same as the desktop CLR
Same JIT, Garbage Collector and virtual machineNew security model
Security Transparency replaces Code Access Security
Not just C# and VB (or C++/CLI or even F#)Ada, APL, Cobol, Eiffel, Forth, Fortran, Lisp, Perl, Pascal, and more
All of these languages are statically compiled
Program in any .NET language
DLR Console
DEMO
DLR adds popular web languages to SilverlightDLR creates MSIL code at runtime and executes itBuilt on a message-passing system
Objects respond to messages based on language semanticsMessages are converted to MSIL and executed
Dynamic method dispatch, dynamic type systemMessages are bound to methods at runtimeDynamic types are CLR types—no marshalling to C#
Dynamic Languages
Limited file system access
IsolatedStorageFile abstracts virtual file system1 MB allocated per-user, per applicationDefine the scope with a using directive
File objects are disposed when scope is destroyed
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{using (StreamWriter writer = new StreamWriter(isoStore)) {
writer.Write("This is isolated storage file."); }
}
Simplified Base Class Library
Web-hosting CoreCLR reduces scenariosNeed to reduce size for click-time installSimplified BCL is based on .NET CFNon-generic collections have been removedLocalization culture information from base OSBackgroundWorker is primary threading mechanismSee BCL team blog for more details
Guidance available to help port existing .NET code
Appdomains and processesEach box represents a separateappdomain running in CoreCLR.
Silverlight 1.1 application in its
own CoreCLR
Silverlight 1.0 application uses XAML
and Javascript
Different browser runs indifferent process so it getsits own copy of CoreCLR.
Silverlight 1.1 application with shared CoreCLR
Another Silverlight 1.1 application
Browser tabs share a single process and share one copy of CoreCLR.
ActiveX host handles all versioning
Versioning and binding transparent to the userActiveX host loads the CLR, creates appdomain and applies policies for that appdomainDLL has access to the XAML and HTML DOMs
XAML can be written dynamically from managed codeEach Silverlight canvas runs in its own appdomain
Platform code can be shared between appdomainsAppdomain gets unloaded when web page unloads
Running a managed program means loading CLRCould use the desktop CLR on Windows……but different CLRs can have different behaviorCoreCLR runs in the same process as other CLRs
Even with a CLR in-process we can still load CoreCLRManaged browser can still host Silverlight with CoreCLRCan have multiple CoreCLRs in one process100% compatibility no matter what CLR is on your machine
Which CLR runs my code?
CoreCLR and CLR side-by-side
DEMO
Native code generation
Same JIT runs on Silverlight and desktop CLRSame code generated on Mac, Windows and desktop
No NGen for Silverlight
Intel Mac support
CoreCLR runs on Intel Mac or Windows machinesPlatform Adaptation Layer adapts system APIs
CoreCLR, Base Class Libraries
and other platform
assemblies
Mac OS X 10.4+Intel machines
WindowsIntel x86
machines
PAL
Execution engine is the same
CoreCLR uses the same execution engine as CLRSame JIT, same GC, same virtual machineSimplified security model—CAS is gone!Transparent, Safe Critical and Critical codeAll user code is transparent
May not access critical code or dataMay not call native code through P/Invoke or Interop
Security Transparency example
WINAPI CreateFile (Critical code) creates the file on the user’s
disk without any validation
Silverlight application (Transparent code)wants to write a file
System.IO.IsolatedStorageFile StreamWriter (SafeCritical code)
verifies the request and calls Windows API
Security Transparency Model
No more evidence, no more permissions, no more policy levels, no more code groupsNo more complicated MSDN documentationNo more stackwalks for code access demandsTransparent code can call public methods, use public types and override methods…
if they are exposed by the platform assemblies or by other application codeif they are Safe Critical or Transparent security
Silverlight is simple, right?
MSIL + Metadata
Your code + .NET Framework
Use the .NET programming skills you already haveC# source code
Running in a web browser simplifies scenarios
Your code uses the simplified Base Class Library
Managed execution Same JIT, execution engine means no surprises
Dynamic language runtime adds new languages
Same CoreCLR runs under any ActiveX host
Security Transparency Model is easier to use
Chess: Javascriptvs. CoreCLR
DEMO
Questions?
Q&A
Shawn Farkas’ blog posts about Silverlight Securityhttp://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx
Silverlight – Get Startedhttp://silverlight.net/GetStarted
Jim Hugunin’s blog about the DLRhttp://blogs.msdn.com/hugunin
BCL team blog posts about Silverlight http://blogs.msdn.com/bclteam/archive/tags/Silverlight/default.aspx
Resources
Where to find these slides (and not much else)http://blogs.msdn.com/apardoe
Silverlight Shanghai team bloghttp://blogs.csdn.net/SilverlightShanghai
Thank you for attending this session with us!
Your suggestions and comments are very important to us. Please help us to complete an evaluation.
© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.