In this article I will try to explain you managed code and unmanaged code in .NET with help of diagram and its execution process.
- Managed Code
- Unmanaged Code
The resource, which is with in your application domain is, managed code. The resources that are within domain are faster.
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
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

Runtime Callable Wrapper unmanaged code execution

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.

santosh tiwariPosted May 11, 2020, 4:23 AM
Dear Mahesh, Kindly provide the link for updated article.
Dharamvir SinghPosted May 6, 2020, 2:39 AM
It created more confusion...
Mahesh ChandPosted Feb 13, 2019, 12:26 PM
This article is being updated.
Kaushik Roy ChowdhuryPosted Jan 28, 2019, 5:18 PM
Hi All, advise all to look at this article if you are really keen to dive deep into the article subject from an authority on an MS resource. The link is https://social.msdn.microsoft.com/Forums/vstudio/en-US/a3e28547-4791-4394-b450-29c82cd70f70/managed-code-vs-unmanaged-code?forum=csharpgeneral
Neeraj AgnihotriPosted Sep 7, 2018, 2:38 AM
Most of the info are confusing and leading to bad explanation of the concept.
Deelip DapkePosted Aug 8, 2018, 11:16 PM
This document is more confusion ....
Nandeshwar BagdePosted Jun 4, 2018, 5:17 AM
Wrong information as diagram are wrong in unmanaged code
AhsanPosted Jun 28, 2017, 10:44 AM
Bad article , i am preparing for an interview :/
dilip tripathyPosted Apr 11, 2017, 8:46 AM
No didn't help . this article just creating confuse. i think u also know this. update it please
Abhishek SinghPosted May 11, 2016, 3:04 AM
both diagrams are wrong
king KabilPosted Dec 17, 2015, 11:24 PM
very usfully
Deepak KumarPosted Oct 4, 2014, 2:02 PM
Article is very nice
Deepak KumarPosted Oct 4, 2014, 2:01 PM
not three time two time. Manage code and unmange code
Nedim SahinPosted Aug 17, 2014, 4:56 PM
The same image is shown three times
Pratik PatniPosted Mar 6, 2013, 11:38 AM
What if I am running a c++ program in Visual Studio i.e. .Net framework environment? Will it be a managed code or unmanaged code?
Anshu SinghPosted Jan 8, 2013, 4:03 AM
Take a look here http://infostuffs.com/2012/12/29/2-understanding-net-the-c-environment/
Dinu MariasPosted Jul 14, 2011, 1:33 PM
thanx...very well said..but where is managed code execution process?
Dinu MariasPosted Jul 14, 2011, 1:33 PM
thanx...very well said..but where is managed code execution process?
Chetnaa DesaiPosted May 25, 2011, 8:21 AM
I fully agree with sam. It would be better before posting article study it properly and corectly.
Sam HobbsPosted Feb 3, 2011, 3:54 PM
Managed code is executed by unmanged code but managed code does not execute unmanaged code. Managed code simply gets out of the way of unmanaged code and lets Windows execute unmanaged code directly. Windows is unmanaged code.
Gunnas S SubashPosted Jan 28, 2011, 6:49 AM
Please check this link, let me clear doubt of the first and second flow chart different. http://www.c-sharpcorner.com/UploadFile/puranindia/ManagedcodeUnmanagedcodeNET06252009005013AM/ManagedcodeUnmanagedcodeNET.aspx
lalit dhakePosted Dec 11, 2010, 1:55 AM
I heard this question so many time in the interviews, So now I cleared about this concept after coming across here......Nice article.
Antony Romar M GPosted Jun 25, 2009, 2:48 AM
I need some more article in Asp.Net that covers[Web Forms, Web Controls, Validation Controls].. Kindly do the needfull, Thankx