Showing posts with label .net Architecture. Show all posts
Showing posts with label .net Architecture. 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.

Monday, August 13, 2018

Common Language Specification &


Common Language Specification
One of the obvious themes of .NET is unification and interoperability between various programming languages. In order to achieve this; certain rules must be laid and all the languages must follow these rules. CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow.
The Common Language Specification is a set of basic language features (constructs and constraints) that serves as a guide for library writers and compiler writers. It allows libraries to be fully usable from any language supporting the CLS, and for those languages to integrate with each other. The Common Language Specification is a subset of the common type system. The CLS is actually a set of restrictions on the CTS. The CLS defines not only the types allowed in external calls, but the rules for using them, depending on the goal of the user.
The Common Language Specification describes a common level of language functionality. The CLS is a set of rules that a language compiler must follow to create .NET applications that run in the CLR. Anyone who wants to write a .NET compliant compiler needs simply to follow these rules and that's it.
Base Class Library
The .NET Framework base class library contains the base classes that provide many of the services and objects you need when writing your applications. The class library is organized into namespaces. The .NET Framework Class Library (FCL) is a set of managed classes that provide access to system services. File input/output, sockets, database access, remoting, and XML are just some of the services available in the FCL. Importantly, all the .NET languages rely on the same managed classes for the same services. This is one of the reasons that, once you have learned any .NET language, you have learned 40 percent of every other managed language. The same classes, methods, parameters, and types are used for system services regardless of the language. This is one of the most important contributions of FCL.


Sunday, August 12, 2018

Managed Code V/S Unmanaged Code

Managed Code & Unmanaged Code
Managed Code:
Managed code is the code that is written to target the services of the managed runtime execution environment such as Common Language Runtime in .Net Technology. This code is directly executed by CLR with help of managed code execution. Any language that is written in .NET Framework is managed code.
In simple terms the code which is executed by CLR (Common Language Runtime) is called Managed Code, any application which is developed in .Net framework is going to work under CLR, the CLR internally uses the Garbage Collector to clear the unused memory and also used the other functionalities like CTS, CAS etc. Managed code uses CLR which in turns looks after your applications by managing memory, handling security, allowing cross - language debugging, and so on.
Unmanaged Code:
Unmanaged code compiles straight to machine code and directly executed by the Operating System. The generated code runs natively on the host processor and the processor directly executes the code generated by the compiler. It is always compiled to target a specific architecture and will only run on the intended platform. All code compiled by traditional C/C++ compilers are Unmanaged Code.
         The managed code is comparatively easier to learn, write and manage. It offer less code writing efforts to the developer. The legacy of library concept is still maintained by the managed category. While writing an unmanaged code, the programmer works closer to the system hardware, thus faces security and memory management issues too. Most of the modern languages under the managed class have been written (directly or indirectly) in the unmanaged C language code. Unlike the newer, the unmanaged code does not need any supporting environment to execute. It’s ready to run just after the source code compilation.

Difference between Managed & Unmanaged Code:


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