O'Reilly C# 5.0 in a Nutshell, 5th Edition 9781449320102 Manual Do Utilizador

Códigos do produto
9781449320102
Página de 21
C# and Windows Runtime
C# 5.0 also interoperates with Windows Runtime (WinRT) libraries. WinRT is an
execution interface and runtime environment for accessing libraries in a language-
neutral and object-oriented fashion. It ships with Windows 8 and is (in part) an
enhanced version of Microsoft’s Component Object Model or COM (see 
Windows 8 ships with a set of unmanaged WinRT libraries which serve as a frame-
work  for  touch-enabled  Metro-style  applications  delivered  through  Microsoft’s
application store. (The term WinRT also refers to these libraries.) Being WinRT, the
libraries can easily be consumed not only from C# and VB, but C++ and JavaScript.
Some WinRT libraries can also be consumed in normal non-
tablet applications. However, taking a dependency on WinRT
gives your application a minimum OS requirement of Windows
8. (And into the future, taking a dependency on the next version
of WinRT would give your program a minimum OS require-
ment of Windows 9.)
The WinRT libraries support the new Metro user interface (for writing immersive
touch-first applications), mobile device-specific features (sensors, text messaging
and so on), and a range of core functionality that overlaps with parts of the .NET
Framework. Because of this overlap, Visual Studio includes a reference profile (a set
of .NET reference assemblies) for Metro projects that hides the portions of the .NET
Framework  that  overlap  with  WinRT.  This  profile  also  hides  large  portions  of
the .NET Framework considered unnecessary for tablet apps (such as accessing a
database). Microsoft’s application store, which controls the distribution of software
to consumer devices, rejects any program that attempts to access a hidden type.
reference assembly exists purely to compile against and may
have a restricted set of types and members. This allows devel-
opers  to  install  the  full  .NET  Framework  on  their  machines
while coding certain projects as though they had only a subset.
The actual functionality comes at runtime from assemblies in
the Global Assembly Cache (see 
) which may superset
the reference assemblies.
Hiding most of the .NET Framework eases the learning curve for developers new to
the Microsoft platform, although there are two more important goals:
• It sandboxes applications (restricts functionality to reduce the impact of mal-
ware). For instance, arbitrary file access is forbidden, and there the ability to
start  or  communicate  with  other  programs  on  the  computer  is  extremely
restricted.
• It allows low-powered Metro-only tablets to ship with a reduced .NET Frame-
work (Metro profile), lowering the OS footprint.
C# and Windows Runtime | 5
Introduction