Académique Documents
Professionnel Documents
Culture Documents
NET Platform
Introduction to the .NET Platform
Namespace
Assembly
● Definition
● Assembly Functions
● Types of Assembly
● Shared Assembly
● Satellite Assembly
● Reference
● DLL Hell
Introduction to the .NET Platform
The .Net Platform is a set of technologies designed to transform the Internet into a full-scale distributed
computing platform.
Core Technologies :
The .NET Framework is an integral Windows component that supports building and running the next
generation of applications and XML Web services.
Portal Server :
To create corporate web portals.
Visual Studio.NET
Visual Studio.NET provides an development environment for building applications on the .NET
Framework.
The Visual Studio .NET Integrated Development Environment (IDE) provides you with a common
interface for developing various kinds of projects for the .NET Framework.
In Visual Studio .NET, an application can be made up of one or more items, such as files and folders. To
organize these items efficiently, Visual Studio .NET has provided two types of containers:
● Projects
● Solutions
➢ Toolbox
The Visual Studio .NET IDE also provides three navigational features:
● Docking
● Tabbed navigation
● Auto hide
Languages in the .NET Framework
● C# – Designed for .NET
● JScript .NET
● J# .NET
● Third-party Languages
C# - Language
C# is a new language having a complete access to the same rich class libraries that are used by seasoned tools
C# is the language of .NET. Most of the .NET Framework is written using C# language. While we can
program .NET in many languages, C# is specifically designed to work well with .NET and to support
component-based programming.
Features of C#
● Consistency
● Modernity
● Simplicity
● Garbage Collection
● Object-Orientation
● Type-safety
● Scalability
● Version support
● Flexibility
VB.NET
Visual Basic .NET is one of the languages that are directed towards meeting the objectives of the .NET
initiative of creating distributed applications.
Visual Basic .NET is a powerful object-oriented language that provides features such as abstraction,
encapsulation, inheritance, and polymorphism.
Features of VB.NET
● Inheritance
● Overloading
● Overriding
● Multithreading
Jscript
Visual Basic .NET and Jscript.NET languages have very similar performance characteristics : Neither of
Jscript.NET is a major evolution of Jscript and the scripting platform, providing a rich, robust language
that builds on the existing script language while providing a flexible way to start building bigger scripts. The key
to all these enhancements in Jscript and Visual Basic is the .NET framework on which they are built.
Web Support
The Internet is quickly evolving from today’s Websites that just deliver UI Pages to browsers to the next
generation of programmable Websites that directly link organizations, applications, services and devices with one
another.
These programmable Websites become more than passively accessed sites they become reusable, intelligent
Web Services. Websites can make information available through Web Services that you can consume on your own
application!
ASP.NET
Active Server Pages (ASP) is the server-side technology for creating dynamic Web pages. The client’s
browser interpreted the HTML tags and displayed the output on the browser screen.
ASP.NET is a server-side Web technology that can be used to develop dynamic and scalable Web
applications. These applications can connect to databases, interact with users and provide asynchronous services.
It is used on a server to build powerful Web Applications. ASP.NET offers several important advantages over
previous Web development models.
Features of ASP.NET
● Enhanced Performance
● Simplicity
● Manageability
● Security
Applications may vary from single-tier desktop applications (applications that follow the single-tier
architecture) to multi-tier applications (applications that follow the two-,three-, or n-tier architecture).
Single-tier architecture
A single executable file handles all functions relating to the user, business, and data service layers.
Two-tier architecture
● Client
● Server
Three-tier architecture
All the three service layers reside separately, either on the same machine or on different machines.
n-tier architecture
Uses business objects for handling business rules and data access.
The .NET Framework is an integral Windows component that supports building and running the next
generation of applications and XML Web services.
It actually runs the code manages so many things for example code execution, garbage collection, memory
allocation, thread management etc.
It contains .NET libraries, which are collection of namespaces and classes. The classes and namespaces are
kept in a systematic way and can be used in making any application, code reusability etc.
The root namespace of .NET framework is System; with this namespace many namespaces like web
(system. web), data (system. data), windows (system. windows) are generated which can be further have their
namespaces.
Benefits of the .NET Framework
● Extensible classes
● Multi-platform applications
● Multi-language integration
● Ease of deployment
CLR is the Common Language Runtime and it forms the heart of the .NET Framework.
All languages have runtime and its responsibility of the runtime to take care of code execution of the
program. For (Eg) .NET has CLR, Java has Java has JVM
Responsibilities of CLR :-
● Garbage Collection
● Code Verification
Garbage Collection
When objects are not referred GC automatically releases those memories thus by providing efficient
memory management.
For (Eg.) Program has rights to edit or create a new file but the security configuration of machine does not
allow the program to delete a file.
It revolves around two concepts code groups and named permission set. Each .net assembly is a member of
particular code group and each group is granted the permission specified in the named permission set.
Code Verification
This ensures proper code execution and type safety while the code runs.
It prevents the source code to perform illegal operation such as accessing invalid memory locations etc.
IL to Native Translators
CLR uses JIT and compiles the IL code to machine code, and then executes.
CLR also determines depending on platform what is optimized way of running the IL code.
Class Loader
Manages metadata in addition to the loading and layout of classes.
Code Manager
Garbage Collector
Security Engine
Provides evidence based security that is based on the origin of code and the use
Debug Engine
Allows to debug the application and trace the execution of code.
Type Checker
Will not allow unsafe casts or uninitialized variables. MSIL can be verified to guarantee Type Safety.
Exception Manager
COM Marshaller
Provides marshalling to and from COM
Integrates code with run time that supports .NET Framework Class Library.
The code runs under the environment of CLR is called “Managed Code”.
But if you are using third party software VB 6 or VC++ component they are “Unmanaged code” as .NET
runtime (CLR) does not have access control over the source code execution of the language.
Defines how types are declared, used and managed in the runtime and is also an important part of the
runtime support for cross language integration.
Value Types
● Stored in Stack
Reference Types
● Stored in heap
The idea is that any program which uses CLS complaint types can inter operate with any .NET
program written in any .NET languages.
Intermediate Language
All the .NET source code is compiled to IL. This IL is then converted into machine code at the point where the
software is installed or at run time by JIT compiler.
● If you run IDASM.EXE from the path you will be popped with the IDASM exe program. Click on file and
browse to the respective directory for the DLL whose assembly you want to view.
● After you select the DLL you will be popped with a tree view details of the DLL is shown in ILDASM view.
● On double clicking on manifest you will be able to view the details of assembly, internal IL code in Manifest
view
Pre JIT
It compiles complete source code into native code in a single compilation cycle. This is done at the time of
deployment of the application.
Econo JIT
It compiles only those methods that called at runtime. However, these compiled methods are removed when
they are not required.
Normal JIT
It compiles only those methods are called at runtime. These methods are compiled the first time they are
called, and then they are stored in cache. When the same methods are called again, the compiled code from cache
is used for execution.
Namespace
In our object oriented world, many times it is possible that programmers will use the same class name. By
qualifying Namespace with Class Name this collisions is able to be removed.
Assembly
Assembly Definition
● They contain the type and resources that are useful to make an application.
● An assembly can have four parts: Manifest, Type Metadata, MSIL and Resource file.
Assembly Functions
● It contains code that the common language runtime executes. Microsoft intermediate language (MSIL) code
in a portable executable (PE) file will not be executed if it does not have an associated assembly manifest. Note
that each assembly can have only one entry point (that is, DllMain, WinMain, or Main).
Every type's identity includes the name of the assembly in which it resides. A type called MyType loaded in the
scope of one assembly is not the same as a type called MyType loaded in the scope of another assembly.
The assembly's manifest contains assembly metadata that is used for resolving types and satisfying resource
requests. It specifies the types and resources that are exposed outside the assembly. The manifest also enumerates
The assembly is the smallest versionable unit in the common language runtime; all types and resources in the
same assembly are versioned as a unit. The assembly's manifest describes the version dependencies you specify for
When an application starts, only the assemblies that the application initially calls must be present. Other
assemblies, such as localization resources or assemblies containing utility classes, can be retrieved on demand. This
Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the
assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in PE files.
You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and
are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.
Assembly Types
Private
A private assembly is normally used by a single application, and is stored in the application's directory, or a
sub-directory beneath.
Public / Shared
A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies
maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will
The runtime enforces versioning constraints only on shared assemblies, not on private assemblies.
● Sign your DLL/EXE with private key by modifying assembly information file.
● Each computer where the common language runtime is installed has a machine-wide code cache called the
global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by
● You should share assemblies by installing them into the global assembly cache only when you need to.
Steps :-
● Recompile project, then install it to GAC by either drag & drop it to assembly folder
(or)
gacutil -i abc.dll
Satellite Assembly
When you write a multilingual or multi-cultural application in .NET, and want to distribute the core
application separately from the localized modules, the localized assemblies that modify the core application are
Assembly Reference
We can dynamically reference an assembly by providing only partial information such as specifying only the
assembly name.
When you specify a partial assembly reference, the runtime looks only in the application.
A full assembly reference includes the assembly's text name, version, culture and public key token. It is
required if you reference any assembly that is part of CLR or any assembly located in GAC.
Is the ability to run multiple versions of an application or component on the same computer. You can have
multiple versions of CLR and multiple versions of applications and components that use a versions of CLR on the
same computer at the same time.
Since the versioning is applicable to the shared assemblies and not to the private assemblies.
Two applications one using private assembly and one using shared assembly cannot be stated as side-by-side
execution.
DLL Hell
Prior to the .NET Framework, application shared DLL files. If one application needed a new version of the
DLL, it would update DLL during the installation. As a result of this update, the other programs using DLL may
no longer function properly. These DLL versioning issues are commonly referred to as DLL Hell.
In .NET environment if the application requires a particular version of a DLL, you can specify that version
in the application. The runtime ensures that correct version of the DLL is available for application. Thus runtime
allows multiple versions of DLL to exist and run at the same time.
Assembly versioning
All versioning of assemblies that uses CLR is done at the assembly level. The assembly version information is
stored in manifest.
The assembly version number, which together with the assembly name and culture information is part of the
assembly's identity.
Each assembly has a version number as part of its identity. As such, two assemblies that differ by the version
number are considered by the run time to be completely different assemblies.
The version number is physically represented as four part string with the following format:
Major or Minor
Changes to the major or minor portion of the version number indicate an incompatible change. Under this
convention then, version 2.0.0.0 would be considered incompatible with version 1.0.0.0.
Examples of an incompatible change would be a change to the types of some method parameters or the
removal of a type or method altogether. Build. The Build number is typically used to distinguish between daily
builds or smaller compatible releases. Revision. Changes to the revision number are typically reserved for an
incremental build needed to fix a particular bug. You'll sometimes hear this referred to as the "emergency bug
fix" number in that the revision is what is often changed when a fix to a specific bug is shipped to a customer.
Assembly Manifest
- Version of Assembly
- Security Identity
- Scope of Assembly
– Stored in either a PE file with MSIL code or standalone PE file that contains only assembly manifest
information.
Manifest describes the assembly itself. Assembly name, version number, culture information. Strong name, list
While the Metadata describes the contents within the assembly. Like classes, interfaces, namespaces, base class,
Strong Name
● A name that consists of an assembly's identity—its simple text name, version number, and culture
information (if provided)—strengthened by a public key and a digital signature generated over the
● After generation of the file you can view the SNK file in a simple notepad.
● After the SNK file is generated its time to sign the project with this SNK file.
● Click on Project properties and browse the SNK file to the respective folder and compile the project.
Serialization
Binary Serialization :- Preserves the fidelity, which is useful for preserving the state of an object between
different invocations of an application.
XML Serialization :- Serializes only public properties and fields and does not preserve fidelity. This is useful
when you want to provide or consume data without restricting the application that uses the data.
Reflection
● All .NET compilers produce metadata about the types defined in modules they produce. The metadata is
packed along with the module and can be accessed by a mechanism called Reflection.
● System.Reflection namespace contains classes that can be used to interrogate the types of module / assembly.
App Domain
● The primary purpose of the AppDomain is to isolate an application from other applications. Win32 processes
provide isolation by having distinct memory address spaces. This is effective, but it is expensive and doesn't scale
well.
● The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in
the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each
other's memory.
● Objects in different application domains communicate either by transporting copies of objects across
● MarshalByRefObject is the base class for objects that communicate across application domain boundaries
● Objects that do not inherit from MarshalByRefObject are implicitly Marshal By Value. When a
remote application references a marshal by value object, a copy of the object is passed across application
domain boundaries.
Delay Signing
During development process, strong name keys to be exposed to developer which is not good practice from
security aspect, In such situations you can assign the key later on and during development you can use delay
signing.
[assembly:AssemblyKeyFileAttribute(“mykey.snk”)]
[assembly:AssemblyDelaySignAttribute(true)]
The compiler inserts the public key into the assembly manifest and reserves space in the PE file for the full
strong name signature. The real public key must be stored while the assembly is built so that other assemblies that
reference this assembly can obtain the key to store in their own assembly's reference.
Sn-Vr myAssembly.dll
The assembly does not have strong name signature, the verification of that signature must be turned off, you
Just before shipping, submit the assembly with -R option with the Strong Name tool. The above code signs an
assembly myAssembly.dll with a strong name using the sgKey.snk key pair.
Code DOM
● Once Code Dom is created, we can generate the source code in any .NET complaint languages.
● The utility allows you o run the JIT compiler on your assembly's MSIL and generate native machine code
● After the image is created .NET runtime will use the image to run the code from cache rather than from the
hard disk.
● Running Ngen.exe on an assembly potentially allows the assembly to load and execute faster, because it
restores code and data structures from the native image cache rather than generating them dynamically.
● To un-install an assembly and its dependencies from the native image cache by running the following
● In .NET 2.0 there is a service(.NET Optimization Service) which can precompile managed assemblies in the
background. You can schedule your assemblies to be precompiled asynchronously by queuing them up with
ngen.exe install<assemblyname>/queue<priority>
● Assemblies which are critical to your application's start up time should be either be precompiled
synchronously or asynchronously with priority 1. Priority 1 & 2 are compiled aggressively, while priority 3
● Synchronously pre-compiling your critical assemblies guarantees that native images will be available prior to
the first time, when the end user launches the application but increases the time taken to run your