Managed code and unmanaged code in .NET

In this article I will try to explain you managed code and unmanaged code in .NET with help of diagram and its execution process.

.NET supports two kind of coding

  1. Managed Code
  2. Unmanaged Code

Managed Code

The resource, which is with in your application domain is, managed code. The resources that are within domain are faster.

The code, which is developed in .NET framework, is known as managed code. This code is directly executed by CLR with help of managed code execution. Any language that is written in .NET Framework is managed code.

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_COM.gif

Unmanaged Code

The code, which is developed outside .NET, Framework is known as unmanaged code.

Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system. Background compatibility with code of VB, ASP and COM are examples of unmanaged code. 

Unmanaged code can be unmanaged source code and unmanaged compile code.

Unmanaged code is executed with help of wrapper classes.

Wrapper classes are of two types: CCW (COM Callable Wrapper) and RCW (Runtime Callable Wrapper).

Wrapper is used to cover difference with the help of CCW and RCW.

COM callable wrapper unmanaged code execution

unmanaged_code_COM.gif

Runtime Callable Wrapper unmanaged code execution

unmanaged_code_RCW.gif

I hope that this article would have helped you in understanding managed and unmanaged .NET.

Your feedback and constructive contributions are welcome.  Please feel free to contact me for feedback or comments you may have about this article.


Similar Articles