What is the difference between Managed code and Unmanaged code in .Net?

Managed code Vs Unmanaged code

Any code running under CLR(Common Language Runtime)is called Managed code and opposite is called unmanaged code.

Managed Code

When a programmer write code in .Net languages such as C# or VB, he is writing managed code. Because any code which executes under CLR is called managed code. Managed code is subjected to certain rules and has so many benefits. But the rules are so easily for a programmer as the compiler must generate an MSIL(Microsoft Intermediate Language) file which target CLR and use the .Net class libraries. While following certain rules, there are so many benefits like, modern memory management, the ability to mix languages(Use of VB library in C# programming or vice versa), more security support, version controlling and a clean way of software components interaction. This article is about Managed code Vs Unmanaged code

Unmanaged Code

Just opposite to managed code is called unmanaged code. Unmanaged code does not execute under CLR. We cannot write unmanaged code in C# or VB., because the run under CLR. But in windows, prior to the creation of .Net framwork, it uses unmanaged code. For Example, COM components, COM+ Services and Win32 API are examples for unmamaged codes. So it is possible to interact between managed code and unmanaged code in windows.

Leave a Reply

%d bloggers like this: