Assemblies in the .NET CLR - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Assemblies in the .NET CLR

Description:

Pransih Kumar, Prgroam Manager on Visual C libratries team (ATL, MFC, ATL Server) ... probably calls al.exe anyways. Configuration parameters. Name. simple string ... – PowerPoint PPT presentation

Number of Views:916
Avg rating:3.0/5.0
Slides: 14
Provided by: donalla
Category:
Tags: clr | net | anyways | assemblies

less

Transcript and Presenter's Notes

Title: Assemblies in the .NET CLR


1
Assemblies in the .NET CLR
  • Presented Monday, 21 May 2001
  • by Donal Lafferty

2
References
  • Online conversation with
  • Pransih Kumar, Prgroam Manager on Visual C
    libratries team (ATL, MFC, ATL Server)
  • Ronald Laeremans, Program Manager for C
    compiler
  • Assemblies
  • Closest thing .NET has to COM objects
  • versioning
  • contain multiple classes and interface
    definitions
  • Framework SDK
  • Notes from Understanding Managed Execution
  • .NET Framework Developers Guide

3
Assembly Concepts
  • WRT creation time, there are two flavours
  • Dynamic and Static
  • Dynamic are defined at runtime, static are
    defined at development time.
  • Dynamic need not be persisted on disk, but static
    always will be.
  • Dynamic created using System.Reflection.Emit.
  • Dynamic assemblies correspond to compiled
    scripts.
  • Assemblies are a logical unit of distribution
  • Single-file and multi-file assemblies both exist.
  • Ex. Person class starts off as one file, but a
    later version includes three files

Person V1.2.0.0
Person V1.0.0.0
Person.DLL
People.MCL
Address.DLL
Person.MCL (Manifest)
Manifest
4
Assembly Concepts
  • Assembly Manifest Contents
  • Assembly name
  • Textual string
  • Version info
  • Major.Minor.Build.Revision (x.x.x.x)
    (compatibility version)
  • Shared name
  • public key from publsher
  • hash of file containing the manifest signed w/
    publishers private key
  • Target
  • Target culture, processor and O/S
  • Assembly file list
  • hash of each file in assembly
  • Relative path to file from manifest.
  • Docs say files must be in same directory, but I
    think this includes subdirectories.
  • Type reference
  • Identifies supported types
  • Dependency list
  • other assemblies statically referenced by the
    assembly.
  • Assemblys name, metadata (version, culture,
    O/S), public key (shared name)

5
Assembly Concepts
  • Assembly design guidelines
  • Assemblies are the unit of modularity, so group
    classes with similar needs in the following
    categories
  • Version
  • Reuse
  • Security
  • Scoping

6
Creating Assemblies
  • Creation tools
  • al.exe
  • IDE
  • probably calls al.exe anyways
  • Configuration parameters
  • Name
  • simple ? string
  • shared (I.e. Strong) ? string, public key,
    encrypted hash
  • Deployment location
  • Applications root directory or subdirectory
  • Global assembly cache
  • Loader Optimization
  • Assembly creation time
  • Single Domain
  • More memory for multiple versions, but smaller
    JIT-code
  • Multi-Domain, same code in each domain
  • Multi-Domain, different code in each domain
  • Multi-Domain cannot be unloaded.
  • Load time

7
Shared Name
  • Key points
  • Guaranteed uniqueness
  • Key, Hash and string name
  • Ownership over name
  • via private key
  • Does not imply Trust!
  • Creation
  • sn.exe
  • Usage
  • Strong name assemblies stored in Global Assembly
    Cache (GAC)
  • Strong name assembly referenced by name and token
  • token is shorter version of public key.
  • Binding occurs with assembly whose key matches
  • Binding results in integrity check.

8
Global Assembly Cache
  • Runtime cache has two parts
  • Download cache
  • Global assembly cache
  • Deploying to cache
  • al.exe, WindowsInstaller, WindowsExplorer
  • Why use for assemblies?
  • Performance
  • No verfication at load time, load is faster,
    locating assembly much faster.
  • Integrity checking
  • At install time
  • File delection security
  • Only admin can delete
  • Versioning integrated with loader
  • Questionable.
  • QFE easier
  • Single assembly needs to be updated.

9
Locating an Assembly
  • 1. Assembly load intiated when assembly is
    referenced
  • Static reference recorded in an assemblies
    dependency list.
  • Dynamic reference via System.Reflection.Assembly.L
    oad
  • Assembly Reference consists of
  • name
  • version
  • culture
  • originator
  • (I.e. reference to the publishers public key)
  • If reference is missing originator, then
    versioning is not adherred to.

10
Locating an Assembly
  • 2. Apply version policy specified by config file
  • Determine configuration file
  • For an exe, the configuration file has the same
    name as the .exe, but ends with a .cfg.
  • For an applet, the HTML specifies the
    configuration file.
  • File is written in XML
  • Determine revisions to version requirements
  • BindingRedir tag can explicitly remap a version,
    all versions and change the QFE policy.
  • QFE is Quick Fix Engineering
  • File is written XML
  • Ex.
  • ltBindingPolicygt
  • ltBindingRedir NamePerson
  • Originator32ab4ba45e0a69a1
  • Version VersionNew2.1.0.0
  • UseLatestBuildRevisionyes/gt
  • lt/BindingPolicygt
  • Determine revisions to version requirements
  • BindingMode tag can explicitly select safe mode
    which forces the desired assembly version to be
    that record at compile time.
  • Ex

11
Locating an Assembly
  • Locating assembly
  • No originator, no versioning
  • Codebase approach
  • Config file can explicity select location using a
    URL (file, http, ftp, etc.)
  • Ex
  • ltAssembliesgt
  • ltCodeBaseHint NamePerson
  • Originator8e47bf1a5ed0ec84
  • Version1.0.0.1
  • CodeBasehttp//www.dsg.cs.tcd.ie/1ba2/person.
    dll/gt
  • lt/Assembliesgt
  • Current binding context second alternative
  • Corresponds to location from which referencing
    assembly was obtained.
  • Probing approach
  • Probing stops when 1st acceptable version found.
  • Search for file with assembly name and extension
    of .MCL, .DLL or .EXE
  • Start at AppBase
  • Location of 1st assembly loaded in AppDomain
  • URL, not file name!

12
Locating an Assembly
  • 4. Global Assembly Cache
  • QFE policy will dictate GAC look up even if
    probing finds a version.
  • If probing/codebase failes, Global Assembly Cache
    (GAC) look up occurs.

13
Misc Points
  • Namespace support
  • Runtime type name consists of two logical parts
  • Assembly name
  • type name in assembly
  • Namespace not supported natively
  • Implemented at language level
  • Ex.TCD.Reification and TCD.Terminal can both be
    in 1BA2.DLL
  • Side by side execution
  • Ex. two versions of assembly can be loaded into
    separate processes
  • Must make sure no conflicts between system
    resources captured by each.
  • Ex. two versions of assembly can be loaded into
    separate AppDomains
  • Must make sure no conflicts between process
    resources captured by each.
  • Security
  • AuthentiCode signature implies trust, but is
    separate from strong naming
  • Prob. a DLL standard.
  • Assembly makes permission request to security
    system for required access.
  • Policy set by adminstrator.
Write a Comment
User Comments (0)
About PowerShow.com