Showing posts with label CLR. Show all posts
Showing posts with label CLR. Show all posts

Thursday, August 16, 2018

Metadata


Metadata
Metadata in .Net is binary information which describes the characteristics of a resource . This information include Description of the Assembly , Data Types and members with their declarations and implementations, references to other types and members , Security permissions etc. A module's metadata contains everything that needed to interact with another module. In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information. In order for two systems, components, or objects to interoperate with one another, at least one must know something about the other.
During the compile time Metadata created with Microsoft Intermediate Language (MSIL) and stored in a file called a Manifest . Both Metadata and Microsoft Intermediate Language (MSIL) together wrapped in a Portable Executable (PE) file. During the runtime of a program Just In Time (JIT) compiler of the Common Language Runtime (CLR) uses the Metadata and converts Microsoft Intermediate Language (MSIL) into native code. When code is executed, the runtime loads metadata into memory and references it to discover information about your code's classes, members, inheritance, and so on. Moreover Metadata eliminating the need for Interface Definition Language (IDL) files, header files, or any external method of component reference.
Metadata stores the following information:
  • Description of the assembly
    • Identity (name, version, culture, public key).
    • The types that are exported.
    • Other assemblies that this assembly depends on.
    • Security permissions needed to run.
  • Description of types
    • Name, visibility, base class, and interfaces implemented.
    • Members (methods, fields, properties, events, nested types).
  • Attributes
    • Additional descriptive elements that modify types and members.

Tuesday, August 7, 2018

Common Type System

Common Type System ( CTS )


The language interoperability, and .NET Class Framework, are not possible without all the language sharing the same data types. What this means is that an "int" should mean the same in VB, VC++, C# and all other .NET compliant languages. The common type system defines how types are declared, used, and managed in the common language runtime, and is also an important part of the runtime's support for cross-language integration. The Common Type System (CTS) standardizes the data types of all programming languages using .NET under the umbrella of .NET to a common data type for easy and smooth communication among these .NET languages.
          For example, when we declare an int type data type in C# and VB.Net then they are converted to int32. In other words, now both will have a common data type that provides flexible communication between these two languages.



The common type system performs the following functions:
  • Establishes a framework that helps enable cross-language integration, type safety, and high-performance code execution.
  • Provides an object-oriented model that supports the complete implementation of many programming languages.
  • Defines rules that languages must follow, which helps ensure that objects written in different languages can interact with each other.
  • Provides a library that contains the primitive data types (such as Boolean, Byte, Char, Int32, and UInt64) used in application development.
-S
     - Prof. Shardul P. Patil

Monday, August 6, 2018

Common Language Runtime

Common Language Runtime


The CLR stands for Common Language Runtime is an Execution Environment. It works as a layer between Operating Systems and the applications written in .Net languages that conforms to the Common Language Specification (CLS).
The common language runtime (CLR) is the core runtime engine for executing applications in the .NET Framework. The CLR allows an instance of a class written in one language to call a method of the class written in another language. At the base level, it is the infrastructure that executes applications, and allows them to interact with the other parts of the Framework. The code which runs under the CLR is called as Managed Code. Programmers need not to worry on managing the memory if the programs are running under the CLR as it provides memory management and thread management. The main function of Common Language Runtime (CLR) is to convert the Managed Code into native code and then execute the Program. It acts as a layer between Operating Systems and the applications written in .Net languages.
Compilers and tools expose the common language runtime's functionality and enable you to write code that benefits from this managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code; it benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.
CLR handles the execution of code and provides useful services for the implementation of the program. In addition to executing code, CLR provides services such as memory management, thread management, security management, code verification, compilation, and other system services.
The main function of Common Language Runtime (CLR) is to convert the Managed Code into native code and then execute the Program. The Managed Code compiled only when it needed, that is it converts the appropriate instructions when each function is called . The Common Language Runtime (CLR) 's just in time (JIT) compilation converts Intermediate Language (MSIL) to native code on demand at application run time.
Functions of the CLR:
Class Loader:
Used to load all classes at run time.
MSIL to Native code compiler:
The Just In Time (JTI) 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 deallocate them to reduce memory.
Thread Support:
It supports multi-threading of our application.
Exception Handler:
Exception Manager will handle exceptions thrown by application by executing catch block provided by exception, it there is no catch block , it will terminate application.

- Prof. Shardul P. Patil