0% found this document useful (0 votes)
37 views6 pages

CLR

Common Language Runtime

Uploaded by

Amir Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
37 views6 pages

CLR

Common Language Runtime

Uploaded by

Amir Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
Visual Programming with C# MCS Page #1 CLR (Common Language Runtime) + CLR stands for Common Language Runtime. CLR is the Virtual Machine component of Microsoft .NET Framework. It is the run-time environment in the NET Framework that manages the execution of Programs written in any language that uses the .NET Framework like C#, VB.Net, F# etc. + CLR makes development process easier by providing the various services. + Programmers write code in any language, including VB.Net, C# and Fi# then they compile their programs Into an intermediate form of code called CIL in a portable execution file (PE) that can be managed and used by the CLR and then the CLR converts it into machine code to be executed by the processor. + The formation about the environment, programming language, its version and what class libraries will be used for this code are stored in the form of metadata with the compiler that tells the CLR how to handle this code. + The CLR allows an instance of a class written in one language to call a method of the class written in another language. Waseca Creates | managed assembly (exe or .d MSIL Metadata 1L metadata & references loaded by CLR -NET Framework ‘Common Language Runtime Security / Garbag Collection / 31T Compiler -NET Framework Class Libraries t Converted to native machine code Operating System | Hafiz Saeed Ahmad Assistant Professor, HOD Department of Computer Se. Khawaja Farid Govt. Post Graduate College Rahim Yar Khan ual Programming with C# MCS Page #2 ‘The CLR converts CLL (Common Intermediate Language) code to native code. dource code bytecode Native code ce VB.NET compiler CLR ve.NET Clk code =§ ————+> Native code | Otmer wer _Other compiler | language Compile tine Runtime: Functions of the CLR Convert code into CIL (Common Intermediate Language) convert the MSIL code / Bytecode to native code Exception handling Type safety Memory management (using the Garbage Collector) Thread management Code access security Improved performance Language independency Platform independency Architecture independency Components of the CLR + Class Loader Used to load all classes at run Ie. + MSIL to Native code (MSIL > Microsoft Intermediate Language) The Just In Time (JIT) compiler will convert MSIL code into native code. + Code Manager It manages the code at run time. + Garbage Collector It manages the memory. Collect all unused objects and de-allocate them to reduce memory. + Thread Support It supports multithreading of our application. + Exception Handler Ithandles exceptions at run time. CLR (Common Language Runtime) is the foundation of .NET Framework Hafiz Saced Ahmad Assistant Professor, HOD Department of Computer Se. Khawaja Farid Govt. Post Graduate College Rahim Yar Khan Visual Programming with C# MCS Page #3 Q. Explain Managed and Un-Managed Code [Managed Code and Unmanaged code :NET supports two kind of coding + Managed Code + Unmanaged Code Managed code v The code, which is developed in .NET framework, is known as managed code. e.g. the code written in .NET language like C#, VB.NET. Managed code runs inside the environment of CLR i.e. .NET runtime. ¥ Managed code supplies the metadata necessary for the CLR to provide services such as memory management, cross-language integration, code access security, Garbage collection and automatic i objects. ime control. of Y All code based on IL executes as managed code. Y Any language that is written in .NET Framework is managed code. v The managed compiler translates the associated *.cs, *.vb code files into low- level .NET CIL code that is similar to Java bytecode v Hence, MSIL is one of the programming languages supported by the NET Framework where we can create, build and compile .NET applications by CIL. C+HICLICode | __ VB.NET Code aseeESeR. 1D pe VB Compiler CLiCompiter | wocene | chexe es Hafiz Saced Ahmad Assistant Professor, HOD Department of Computer Se. Khawaja Farid Govt. Post Graduate College Rahim Yar Khan Visual Programming with C# MCS Page #4 Un-Managed Code: + The code not written in .NET language and MSIL (Microsoft Intermediate Language) does not understand what it is and cannot run under CLR; like third-party controls we used in our .NET applications which is not created In .NET languages. + E.g. code written in Visual C++, VB6, FoxPro ete. is an example of unmanaged code. + Win32 API is also an example of unmanaged code + Managed code is not compiled to machine code but to an intermediate language + Unmanaged code is compiled to machine code and therefore executed by the OS directly. NOTE First of all understand this, before .NET framework, Microsoft were providing the stand-alone products like MFC (Visual C++), VB6, FoxPro etc. MFC stands for Microsoft Foundation Classes. In 2002, Microsoft combined its products and made .NET framework. Now there is a difference between how code was executed before and how code is managed and executed in .NET framework. Microsoft introduced concept of CLR with .NET framework which compiles the code coming from any supported language of NET framework and provide additional functionalities like Memory management, Garbage collection, Performance improvements, handling security, cross-language integration etc. But, such CLR features weren't available directly before. Note: ‘The Microsoft Foundation Class (MFC) Library is a collection of classes that can be used in building application programs. The classes in the MFC Library are written in the C+ programming language. The MFC Library saves a programmer time by Providing code that has already been written. It also provides an overall framework for developing the application program. Hafiz Saced Ahmad Assistant Professor, HOD Department of Computer Se. Khawaja Farid Govt. Post Graduate College Rahim Yar Khan Visual Programming with C# MCS Page #5 Q. Write a note on .Net Framework class library? «Net Framework Class Library (FCL) The .Net Framework class library (FCL) provides the core functionality of .Net Framework architecture. It includes a huge collection of reusable classes, interfaces, and value types. The FCL speed up and optimize the development Process and provide access to system functionality, Objectives: The Framework Class Library (FCL) contains thousands of classes, from graphics to /O to networking to XML processing. The goal of the FCL is to Present an abstract, portable view of the underlying operating system. The FCL provides classes for File /O, Database access and Data structures ete. + The .Net Framework class library (FCL) organized in a hierarchical tree structure and it is divided into Namespaces. + Namespaces is a logical grouping of classes/types for the purpose of identification. ‘+ FCL provides the consistent base types that are used in all .NET enabled languages. + The Classes are accessed by namespaces, which reside within Assemblies. +The System Namespace is the root for types in the .NET Framework. + The .Net Framework class library (FCL) classes are managed classes that provide access to System Services. The .Net Framework class library (FCL) classes are object oriented and easy to use in program developments. Moreover, third-party components can integrate with the classes in the .NET Framework. The FCL includes types that perform the following functions: Represent base data types and exceptions Encapsulate data structures. Perform 1/0. Access information about loaded types. Invoke .NET Framework security checks, Provide data access, rich client-side GUI, and server-controlled, client-side cul. Hafiz Saced Ahmad Assistant Professor, HOD Department of Computer Se. Khawaja Farid Govt. Post Graduate College Rahim Yar Khan Visual Programming with C# McS Basic Terms used in .Framework, CLR, Managed and Un-Managed Code CLR Common Language Runtime JVM Java Virtual Machine cIL Common Intermediate Language MSIL Microsoft Intermediate Language ut Just-In Time Compiler cu Common Language Infrastructure FCL Framework Class Library Hafiz Saced Ahmad Assistant Professor, HOD Department of Computer Sc. Khawaja Farid Govt. Post Graduate College Rahim Yar Khan

You might also like