net framework danish sami ug lead.netfoundry
TRANSCRIPT
.NET Framework
Danish SamiUG Lead .NetFoundryhttp://www.dnfug.com
Common Language RuntimeCommon Language Runtime
Base Framework ClassesBase Framework Classes
Data and XML ClassesData and XML Classes
C# VB.NET J# C++ …C# VB.NET J# C++ …
XML Web XML Web ServicesServices
Web Web FormsForms
ASP.NETASP.NET
Windows Windows FormsForms
.NET Platform Overview
CLI (The .NET Specifications)
Common Language Infrastructure A common type system
The specification that determines how the runtime defines, uses, and manages types
Execution Engine Architecture (runtime) A common Intermediate Language format A small set of base classes A Standard (ECMA-335)
04/19/23BSG Technical Briefing
4
Microsoft’s .NET Implementation
CLR – Common Language Runtime FCL – Framework Class Library
Overview of CLR
Code management (loading and execution) Application memory isolation Verification of type safety Conversion of IL to native code Access to metadata (enhanced type information) Managing memory for managed objects Enforcement of code access security Exception handling, including cross-language
exceptions Interoperation between managed code, COM
objects, and pre-existing DLLs (unmanaged code and data)
Automation of object layout Support for developer services (profiling,
debugging, and so on)
Process
Common Language Runtime
App Domain 1
App Domain 2 App Domain 3
AssemblyAssembly Assembly
Assembly
Overview of CLR Process
Overview of CLR Process
CLR verifies the type safety of an assembly when it is loaded, assuring that isolation between app domains is enforced
Security Policy is enforced based on characteristics of the assembly (evidence)
SideBar - Some Key Terminology
Type Value Types (Int32, String, DateTime, etc) Reference Types (Classes Arrays, Interfaces,
Pointers, Enumerations) Managed Code
Code that runs through the CLR Type Safe Code
Accesses types only in well-defined, allowable ways and doesn’t access memory directly
.NET Building Blocks
Assemblies Modules
Source to Executable
Source Code
Compiler
Module/Metadata/IL
CLR
Assembly/Metadata
Modules
Source code is compiled to .dll (a library)
or .exe (an executable)
Assemblies
A bundle of One or more modules Zero or more Resource files A Manifest Can be strong-named (signed with a
key)
Assemblies One or more files containing type definitions and
resource files
Managed Module IL and Metadata
Managed Module IL and Metadata
Managed Module IL and Metadata
Resource File(.jpg, .html, etc.)
AssemblyContains Manifest of files
Manifest File
Establishes the assembly identity (in the form of a text name), version, culture, and digital signature (if the assembly is to be shared across applications).
Defines what files (by name and file hash) make up the assembly implementation.
Specifies the types and resources that make up the assembly, including which are exported from the assembly.
Itemizes the compile-time dependencies on other assemblies.
Specifies the set of permissions required for the assembly to run properly.
Module/Assembly
Note that many times, an assembly you create may contain just one module
This is the default in a VS.NET project
Hierarchy
Assembly
Modules
Types
Attributes
Constructors
Fields
Methods
Properties
Events
Type Members
.NET Architecture - Metadata
Assembly
Modules
Manifest
Types, Members, References
Reflection
System.Reflection Namespace Uses
Viewing Metadata Type Discovery Dynamic Binding
Strong-Named Assemblies
An digitally signed assembly Strong integrity check Full Name:System.data, version=1.0.3300.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089
Steps to Sign an Assembly
sn.exe –k SampleKey.snk Entry in AssemblyInfo.cs Build
Location of Assemblies
The application's directory or subdirectories. (Easy XCopy deployment)
Global Assembly Cache (Requires a setup package) Assemblies must be strong-named
Global Assembly Cache
Shared assemblies Side by side versioning Control of versions using policy files Caching of downloadable assemblies Requires a “strong-named”
assembly
Adding an Assembly to the Cache
Build a strong-named assembly Drag and Drop into c:\windows\
assembly Or Gacutil -i
Policy Files
An xml file specifying assembly binding information
Control version of assembly that is used by programs regardless of what version they were built with
Deploying a Policy File
Create the xml file Use the assembly linker to include it
in an assembly Install in into the GAC
Assembly Binding Behavior in config files
Can be configured at different levels based on three XML files: Application configuration file. Publisher policy file. Machine configuration file.
Assemblies (the new Components)
Think of and assembly as a component along the lines of a COM Component
It is the unit of versioning, deployment, security, etc.
You may want to break apps into multiple “components”
Garbage Collection
The CLR takes care of disposing of unreferenced objects
.NET Configuration Files
web.config app.exe.config machine.config
Config File Structure
Two main parts <configSections>
Metadata that tells the framework how to parse the rest of the file Includes <sectionGroup> and <section>
Individual Section Groups and Sections <system.web> <system.net> <appSettings> <authorization>
<authentication>
machine.config
machine.config affects all .NET apps C:\WINDOWS\Microsoft.NET\Framework\version\CONFIG\
web.config and app.exe.config files inherit the machine.config master settings
Sections in our app config files can override the inherited settings.
<configSections>
All sections in the config files are specified in <configSections><section name="appSettings" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>