net framework danish sami ug lead.netfoundry

32
.NET Framework Danish Sami UG Lead .NetFoundry http://www.dnfug.com

Upload: margaret-golden

Post on 31-Dec-2015

218 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: NET Framework Danish Sami UG Lead.NetFoundry

.NET Framework

Danish SamiUG Lead .NetFoundryhttp://www.dnfug.com

Page 2: NET Framework Danish Sami UG Lead.NetFoundry

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

Page 3: NET Framework Danish Sami UG Lead.NetFoundry

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)

Page 4: NET Framework Danish Sami UG Lead.NetFoundry

04/19/23BSG Technical Briefing

4

Microsoft’s .NET Implementation

CLR – Common Language Runtime FCL – Framework Class Library

Page 5: NET Framework Danish Sami UG Lead.NetFoundry

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)

Page 6: NET Framework Danish Sami UG Lead.NetFoundry

Process

Common Language Runtime

App Domain 1

App Domain 2 App Domain 3

AssemblyAssembly Assembly

Assembly

Overview of CLR Process

Page 7: NET Framework Danish Sami UG Lead.NetFoundry

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)

Page 8: NET Framework Danish Sami UG Lead.NetFoundry

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

Page 9: NET Framework Danish Sami UG Lead.NetFoundry

.NET Building Blocks

Assemblies Modules

Page 10: NET Framework Danish Sami UG Lead.NetFoundry

Source to Executable

Source Code

Compiler

Module/Metadata/IL

CLR

Assembly/Metadata

Page 11: NET Framework Danish Sami UG Lead.NetFoundry

Modules

Source code is compiled to .dll (a library)

or .exe (an executable)

Page 12: NET Framework Danish Sami UG Lead.NetFoundry

Assemblies

A bundle of One or more modules Zero or more Resource files A Manifest Can be strong-named (signed with a

key)

Page 13: NET Framework Danish Sami UG Lead.NetFoundry

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

Page 14: NET Framework Danish Sami UG Lead.NetFoundry

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.

Page 15: NET Framework Danish Sami UG Lead.NetFoundry

Module/Assembly

Note that many times, an assembly you create may contain just one module

This is the default in a VS.NET project

Page 16: NET Framework Danish Sami UG Lead.NetFoundry

Hierarchy

Assembly

Modules

Types

Attributes

Constructors

Fields

Methods

Properties

Events

Type Members

Page 17: NET Framework Danish Sami UG Lead.NetFoundry

.NET Architecture - Metadata

Assembly

Modules

Manifest

Types, Members, References

Page 18: NET Framework Danish Sami UG Lead.NetFoundry

Reflection

System.Reflection Namespace Uses

Viewing Metadata Type Discovery Dynamic Binding

Page 19: NET Framework Danish Sami UG Lead.NetFoundry

Strong-Named Assemblies

An digitally signed assembly Strong integrity check Full Name:System.data, version=1.0.3300.0,

Culture=neutral, PublicKeyToken=b77a5c561934e089

Page 20: NET Framework Danish Sami UG Lead.NetFoundry

Steps to Sign an Assembly

sn.exe –k SampleKey.snk Entry in AssemblyInfo.cs Build

Page 21: NET Framework Danish Sami UG Lead.NetFoundry

Location of Assemblies

The application's directory or subdirectories. (Easy XCopy deployment)

Global Assembly Cache (Requires a setup package) Assemblies must be strong-named

Page 22: NET Framework Danish Sami UG Lead.NetFoundry

Global Assembly Cache

Shared assemblies Side by side versioning Control of versions using policy files Caching of downloadable assemblies Requires a “strong-named”

assembly

Page 23: NET Framework Danish Sami UG Lead.NetFoundry

Adding an Assembly to the Cache

Build a strong-named assembly Drag and Drop into c:\windows\

assembly Or Gacutil -i

Page 24: NET Framework Danish Sami UG Lead.NetFoundry

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

Page 25: NET Framework Danish Sami UG Lead.NetFoundry

Deploying a Policy File

Create the xml file Use the assembly linker to include it

in an assembly Install in into the GAC

Page 26: NET Framework Danish Sami UG Lead.NetFoundry

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.

Page 27: NET Framework Danish Sami UG Lead.NetFoundry

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”

Page 28: NET Framework Danish Sami UG Lead.NetFoundry

Garbage Collection

The CLR takes care of disposing of unreferenced objects

Page 29: NET Framework Danish Sami UG Lead.NetFoundry

.NET Configuration Files

web.config app.exe.config machine.config

Page 30: NET Framework Danish Sami UG Lead.NetFoundry

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>

Page 31: NET Framework Danish Sami UG Lead.NetFoundry

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.

Page 32: NET Framework Danish Sami UG Lead.NetFoundry

<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"/>