0% found this document useful (0 votes)
194 views32 pages

Unit 1 Introduction To

The document discusses .NET framework and C# programming, describing .NET as a software development environment and runtime for managed code that provides features like interoperability, language integration, and memory management; it also explains that C# code produces assemblies containing CIL code and metadata that are run on the common language runtime.

Uploaded by

Jay Sarda
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views32 pages

Unit 1 Introduction To

The document discusses .NET framework and C# programming, describing .NET as a software development environment and runtime for managed code that provides features like interoperability, language integration, and memory management; it also explains that C# code produces assemblies containing CIL code and metadata that are run on the common language runtime.

Uploaded by

Jay Sarda
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

BS62

ASP .NET PROGRAMMING USING C#

UNIT 1 INTRODUCTION TO .NET


Problems With Previous Languages

 Good code is hard to write


 All system features in any language
 COM problems
 Platform Interoperability
 Automatic memory management
 Object-Oriented features in and between all PLs
 Safety & Security
 Better Access to OS functions
 Interoperate with COM (both as client & server)

LEENA CHAUDHARI - LNGI, SURAT. 2


.NET Solution

• For various problems faced in previous


technologies, the .NET provides the solution.

• The .NET framework is a completely new model for


building systems on the Windows family of
operating systems, as well as on numerous non-
Microsoft operating systems such as Mac OS X and
various Unix/Linux distributions.

LEENA CHAUDHARI - LNGI, SURAT. 3


Introduction To.NET Framework

• A Software development environment


• A runtime engine for managed code
• A platform designed for Internet distributed
software
• In other words:
.NET is not a language (Runtime and a library
for writing and executing written programs in any
compliant language)

LEENA CHAUDHARI - LNGI, SURAT. 4


Features Provided By .NET

• Full interoperability with existing code


• Complete and total language integration
• A common runtime engine shared by all .NET-
aware languages
• A base class library
• A truly simplified deployment model

LEENA CHAUDHARI - LNGI, SURAT. 5


What is .NET

.NET Application

.NET Framework

Operating System + Hardware

LEENA CHAUDHARI - LNGI, SURAT. 6


Building Blocks of .NET Framework

VB VC++ VC# JScript …

Common Language Specification

Visual Studio.NET
ASP.NET: Web Services Windows
and Web Forms Forms

ADO.NET: Data and XML

Base Class Library

Common Language Runtime

LEENA CHAUDHARI - LNGI, SURAT. 7


Cont…

• Two main Component


1. CLR (Common Language Runtime)
• The runtime layer is properly referred to as
the Common Language Runtime(CLR).
• Heart of the .NET framework
• The primary role of the CLR is to locate,
load, and manage .NET types.
• The CLR also takes care of a number of low-
level details such as memory management
and performing security checks.
2. Base Class libraries
LEENA CHAUDHARI - LNGI, SURAT. 8
Common Type System

The Common Type System (CTS) specification fully


describes the entities like all possible data types and
programming constructs supported by the runtime.

It specifies how these entities can interact with each


other.

It also specifies how they are represented in the .NET


metadata format.

LEENA CHAUDHARI - LNGI, SURAT. 9


Common Language Specification

The Common Language Specification (CLS) is a


related specification that defines a subset of common
types and programming constructs that all .NET
programming languages can agree on.

A data type or programming construct, which is


outside the bounds of the CLS, may not be used by
every .NET programming language.

LEENA CHAUDHARI - LNGI, SURAT. 10


Role of Base Class Libraries

Base class library encapsulates various primitives such as


threads, file input/output (I/O), graphical rendering, and
interaction with various external hardware devices.

It also provides support for a number of services required by


most real-world applications.

For example, the base class libraries define types that facilitate
database access, XML manipulation, programmatic security, and
the construction of web-enabled, traditional desktop and
console-based front ends.

LEENA CHAUDHARI - LNGI, SURAT. 11


Introduction to C#

• C# is a programming language that looks very similar to the


syntax of Java and c++.

• C# allows you to overload operators, as well as to create


structures, enumerations, and callback functions (via delegates).

LEENA CHAUDHARI - LNGI, SURAT. 12


Features of C#

1. No pointers required.
2. Automatic memory management through garbage collection
• C# does not support a delete keyword.
3. The C++-like ability to overload operators for a custom type,
without the complexity.
4. Generic types and generic members is very similar to C++
templates.
5. Full support for interface-based programming techniques.

LEENA CHAUDHARI - LNGI, SURAT. 13


General Terms

•C# produces the code that can execute within the .NET runtime.

• The code targeting the .NET runtime is called as managed


code.

• The binary unit that contains the managed code is termed as


assembly.

• Conversely, code that cannot be directly hosted by the .NET


runtime is termed unmanaged code.

LEENA CHAUDHARI - LNGI, SURAT. 14


An Overview of .NET Assemblies

When a *.dll or *.exe has been created using a .NET-aware


compiler, the resulting module is bundled into an assembly.

An assembly contains CIL code, (which is conceptually similar to


Java byte code).

When a block of CIL instructions (such as a method


implementation) is referenced for use by the .NET runtime
engine, CIL code will be compiled.

Assemblies also contain metadata .

LEENA CHAUDHARI - LNGI, SURAT. 15


Metadata

• Information describing ALL characteristics of an assembly


•Exposed types
•Security requirements
•File dependencies
•Developer information (digital signature)
• It is always the job of the compiler (not the programmer) to
produce the latest and greatest type metadata.

• Asp .NET metadata is so careful, assemblies are completely self-


describing entities and so .NET binaries have no need to be
registered into the system registry.

LEENA CHAUDHARI - LNGI, SURAT. 16


Cont…

• Information describing ALL characteristics of an assembly


•Exposed types
•Security requirements
•File dependencies
•Developer information (digital signature)
• It is always the job of the compiler (not the programmer) to
produce the latest and greatest type metadata.

• Asp .NET metadata is so careful, assemblies are completely self-


describing entities and so .NET binaries have no need to be
registered into the system registry.

LEENA CHAUDHARI - LNGI, SURAT. 17


Metadata

• Information describing ALL characteristics of an assembly


•Exposed types
•Security requirements
•File dependencies
•Developer information (digital signature)
• It is always the job of the compiler (not the programmer) to
produce the latest and greatest type metadata.

• Asp .NET metadata is so careful, assemblies are completely self-


describing entities and so .NET binaries have no need to be
registered into the system registry.

LEENA CHAUDHARI - LNGI, SURAT. 18


Metadata

• Metadata is also used by various object browsing utilities,


debugging tools, and the C# compiler itself.

• Metadata is the backbone of numerous .NET technologies


including remoting, reflection, late binding, XML web services, and
object serialization.

LEENA CHAUDHARI - LNGI, SURAT. 19


Manifest

• Special section of metadata stored in every assembly


• Describes assembly version requirements
• Specifies security identity
• Define Scope of assembly
• Resolve references to resources and classes
• Describes how the elements in the assembly relate to each other
• Required set of metadata need for loading the assembly

LEENA CHAUDHARI - LNGI, SURAT. 20


Location of the Manifest

•Included in PE file (exe or dll) along with IL


•Compile standalone (using command-line compiler)

LEENA CHAUDHARI - LNGI, SURAT. 21


Manifest-Assembly Identity

• Assembly Identity
• Assembly name
• File name minus extension
• Version
• Consists of Major.Minor.revision.build numbers
• Culture
• Information on the culture or language the assembly
supports
• Strong name info
• Involves public key and strong name concepts

LEENA CHAUDHARI - LNGI, SURAT. 22


Assembly Variations

• There are two types of Assemblies.


• Single file
• Multi file

• Single File Assemblies


• Most common (and simplest) form of assembly
• Either class library (DLL) or application (EXE)
• When accessed from app dir, does not undergo version
• Fully portable
• If Fx installed on system, no additional files needed

LEENA CHAUDHARI - LNGI, SURAT. 23


Single File Assembly Contents

• Assembly Manifest
• Type Metadata
• MSIL code
• Resources

LEENA CHAUDHARI - LNGI, SURAT. 24


Multi File Assembly

• Involves multiple files compiled into modules


• C# must use command-line compiler to create modules
• Managed C++ can use VS.NET
• Modules can be resources and/or code
• Files not explicitly linked by file system
• Files managed as a unit by CLR

LEENA CHAUDHARI - LNGI, SURAT. 25


Multi File Consideration

• Files require same version


• Version is maintained per assembly, not individual file
• Model of deployment
• Optimize downloading
• Reuse
• Resources/code used by multiple apps
• Type Scope
• Limit type visibility to assembly

LEENA CHAUDHARI - LNGI, SURAT. 26


Multi File Assembly Contents

• Assembly Manifest
• Type Metadata
• MSIL code
• Resources

LEENA CHAUDHARI - LNGI, SURAT. 27


Common Intermediate Language
(CIL)
 CIL is a language that is any particular platform-specific
instruction set.
 According to languages, the associated compiler produces CIL
instructions.
 For example:
 The C# compiler (csc.exe) compiles the source code file, you end
up with a single-file *.exe assembly that contains a manifest, CIL
instructions, and metadata describing each aspect of the
program.

LEENA CHAUDHARI - LNGI, SURAT. 28


Benefits of CIL

 Language integration
 Each .NET-aware compiler produces nearly identical CIL
instructions. Therefore, all languages are able to interact
within a well- defined binary arena.

LEENA CHAUDHARI - LNGI, SURAT. 29


Compiling CIL to Platform-Specific
Instructions

LEENA CHAUDHARI - LNGI, SURAT. 30


Cont…
 Since assemblies contain CIL instructions, rather than
platform-specific instructions, CIL code must be compiled
before use.
 The entity that compiles CIL code into meaningful CPU
instructions is termed a just-in-time (JIT) compiler, which is
also known as Jitter.
 The .NET runtime environment forces a JIT compiler for each
CPU targeting the CLR, each of which is optimized for the
platform it is targeting.

LEENA CHAUDHARI - LNGI, SURAT. 31


LEENA CHAUDHARI - LNGI, SURAT. 32

You might also like