Visual Programming
.NET Framework Basic
General definition
The .NET Framework itself is a new platform designed from the ground up to
target the Internet. And for those of you interested in VB .NET, VB is just
one of the languages that can be used to write software that targets the .NET
Framework.
The Common Language Runtime (CLR) is the execution engine for
the .NET Framework. It is the platform on-top of which managed code runs.
The CLR provides many system services to .NET code, and in a way is
similar to a traditional OS, however it requires a host OS to run.
As I mentioned before, the CLR is an execution or runtime engine. It runs
alongside managed code. Managed code is any code that targets the .NET
Framework. This includes [Link] code, C#, etc.
Code management, by the CLR, includes features such as automatic memory
management, thread management, object oriented infrastructure, type-safety,
and enforced security.
.NET Framework components
• Common Intermediate Language (CIL)
• Common Language Runtime (CLR)
• Just-In-Time (JIT) Compiler
• Common Language Specification
• Framework Class Library (FCL)
Compiler
• Software that translate high-level language ( VB,
C++, Java, C#, etc) to machine language.
• Compiler X can covert high-level Y to machine
language Z.
Problem
• A big problem facing developers is the many
different types of processors that run code.
• Windows, Macintosh, and Unix machines use a
wide variety of hardware, as do personal digital
assistants, cell phones, large computers, and other
platforms.
• One way to make a program work on each of these
devices is to translate the program to the native
instruction
•So if we have 3 programming languages and 3
devices, how many compilers do we need?
•So, how they solved this?!
Two Steps Compilation Process
• Compilation is done in two steps:
– At compile time: compile each language (VB, C#, C++, etc)
to Common Intermediate Language (CIL)
– At runtime: Common Language Runtime (CLR) uses a
Just In Time (JIT) compiler to compile the CIL code to the
native code for the device used
Compile Run
Time Time
Common Intermediate Language (CIL)
• Much like the native languages of devices.
• CIL was originally known as Microsoft Intermediate
Language (MSIL).
• CIL is a CPU- and platform-independent instruction set.
• It can be executed in any environment supporting the .NET
framework
Common Language Runtime (CLR)
• The Common Language Runtime (CLR) manages
the execution of code.
• CLR uses Just-In-Time (JIT) compiler to
compile the CIL code to the native code for device
used.
• Through the runtime compilation process CIL
code is verified for safety during runtime,
providing better security and reliability than
natively compiled binaries.
.NET Framework
Visual Studio .NET
C++ C# VB Perl J# …
Common Language Specification
Visual Studio .NET
ASP .NET Windows
Web Forms Web Services
Mobile Internet Toolkit
Forms
ADO .NET and XML
.NET Framework (Base Class Library)
Common Language Runtime
Operating System
Compilation Process
• So if we have 3 programming languages and 3
devices, how many compilers do we need?
Source Executes
VB C# C++ under the
code management
VB Compiler C# Compiler C++ Compiler
of a virtual
machine.
CIL CIL CIL
Common Language Runtime JIT Compiler
Native Managed Managed Managed Unmanaged
code Code CLR
Code Code Code
CLR Services
Operating System Services
Compiling and Execution
Execution engine
• Common Language Runtime (CLR) is the
execution engine
– loads IL
– compiles IL
– executes resulting machine code
CLR
Runtime
IL machine code Execute
compiler
JIT runtime compile
• CIL is compiled into machine code at runtime by the CLR
– compiles methods as needed
– called just in time (JIT) compile
• JIT compilation model:
– first time method is called the IL is compiled and optimized
– compiled machine code is cached in transient memory
– cached copy used for subsequent calls
Cache
machine code for F()
CIL code
F() JIT runtime Execute
G() compiler
H()
Common Language Specification
• Common Language Specification (CLS) defines
type subset
– required to be supported by all .NET languages
– limiting code to CLS maximizes language interoperability
– code limited to CLS called CLS compliant
Framework Class Library (FCL)
• Namespace: A collection of classes and their
methods. Example: [Link]. Forms
• The .NET Framework class library is a library of
classes, interfaces, and value types that are
included in the Windows Software Development
Kit (SDK).
• Namespaces are stored in DLL files called
assemblies
• .NET applications must have “references” to these
DLLs so that their code can be linked in
• FLC
– Consists of approximately 100 assemblies and over 1000
classes
– Have suffix of .dll
The .NET FCL Namespaces
Some Important .Net Namespaces in FCL
• System Core data/auxiliary classes
• [Link] Resizable arrays + other containers
• [Link] [Link] database access classes
• [Link] Graphical Output classes (GDI+)
• [Link] Classes for file/stream I/O
• [Link] Classes to wrap network protocols
• [Link] Classes to create/manage threads
• [Link] HTTP support classes
• [Link] Classes for writing web services
• [Link] Core classes used by [Link]
• [Link] Classes for Windows GUI apps
• See online help on ‘Class Library’ or use MSDN (3CDs)