Unmanaged code is compiled to machine code and therefore executed by the OS directly. It therefore has the ability to do damaging/powerful things Managed code does not. This is how everything used to work, so typically it’s associated with old stuff like .dlls. M
Managed code is not compiled to machine code but to an intermediate language which is interpreted and executed by some service on a machine and is therefore operating within a (hopefully!) secure framework which handles dangerous things like memory and threads for you. In modern usage this frequently means .NET but does not have to.
Here is some other complimentary explication about Managed code:
- Code that is executed by the CLR.
- Code that targets the common language runtime, the foundation of the .NET Framework, is known as managed code.
- Managed code supplies the metadata necessary for the CLR to provide services such as memory management, cross-language integration, code access security, and automatic lifetime control of objects. All code based on IL executes as managed code.
- Code that executes under the CLI execution environment.