ASP.NET
High-productivity environment for building and running Web services
ASP.NET Data and XML Base Framework Common Language Runtime (CLR)
Operating System
Assembly
An Assembly is the managed equivalent of an EXE/DLL Implements and optionally exports a collection of types It is the unit of versioning, security, and deployment Parts of an Assembly file
Windows PE header CLR header (Information interpreted by the CLR and utilities) Metadata (Type definition and reference tables) Intermediate Language (code emitted by compiler)
Second-Tier
Second-Tier
Web Server
Web Server
Client
Client
Managed code
Code that targets the CLR Any .NET Language, including C#, Visual Basic, C++, Java, Cobol, etc.
Windows
(or other operating oystem)
IL and Metadata
All Managed executables consist of
Intermediate Language (IL) instructions Metadata
IL
CPU independent machine language Just-in-time compiled at runtime
Metadata
Structured information describes programming constructs including
Classes definitions, field and method definitions, parameter lists, return types, etc.
C# Compiler
SomeSources.exe Metadata
A Managed Application
IL
Just-in-Time Compiling
All managed code runs in native machine language However, all managed code is made up of IL and metadata The CLR JIT-compiles the IL and metadata
At execution time Executed directly by CPU
IL
Garbage Collection
class MyClass{ void Method(){ Variable v1; Variable v2; do{ . . .
Objects A and D will be cleaned up because neither is directly or indirectly referenced by code
Remoting
NET Remoting provides a way for application in different machines/domains to communicate with each other. Remoting provides a powerful yet an easy way to communicate with object in different app domains. Any object which executes outside the app domain can be considered as Remote.
Remote objects are accessed via Channels, Channels can be thought of as Transport mechanism to pass messages to and from remote objects. All the method calls along with the parameters are passed to the remote object thru the channel viz. HTTP or TCP.
Marshaling
Marshaling is the act of taking data from the environment you are in and exporting it to another environment. In the context of .NET, marhsaling refers to moving data outside of the app-domain you are in, somewhere else.
Intermediate Language
All .NET compilers produce IL code IL is CPU-independent machine language
Created by Microsoft with input from external commercial and academic language/compiler writers
Method stub is removed and points to compiled code Compiled code is executed In future, when method is called, it just runs
Managed EXE
static void Main() { Console.WriteLine(Hello); Console.WriteLine(Goodbye); }
Console
static void WriteLine()
JITCompiler
static void WriteLine(String)
NativeMethod JITCompiler
(remaining members)
MSCorEE.dll
JITCompiler function { 1. In the assembly that implements the type (Console), look up the method (WriteLine) being called in the metadata. 2. From the metadata, get the IL for this method and verify it. 3. Allocate a block of memory. 4. Compile the IL into native CPU instructions; the native code is saved in the memory allocated in step #3. 5. Modify the methods entry in the Types table so that it now points to the memory block allocated in step #3. 6. Jump to the native code contained inside the memory block. }
23000001: AssemblyRef entry for MSCorLib 01000003: TypeRef entry to System.Console 06000001: MethodDef for Main (FYI)
MethodDef TypeDef
Look-up TypeDef