📜  .NET 中托管和非托管代码的区别

📅  最后修改于: 2021-09-12 11:20:45             🧑  作者: Mango

托管代码是由 .NET Framework 中的 CLR(公共语言运行时)管理的代码。而非托管代码是由操作系统直接执行的代码。以下是托管代码和非托管代码之间的一些重要区别:

Managed Code

Unmanaged Code

It is executed by managed runtime environment or managed by the CLR. It is executed directly by the operating system.
It provides security to the application written in .NET Framework. It does not provide any security to the application.
Memory buffer overflow does not occur. Memory buffer overflow may occur.
It provide runtime services like Garbage Collection, exception handling, etc. It does not provide runtime services like Garbage Collection, exception handling, etc.
The source code is compiled in the intermediate language known as IL or MSIL or CIL. The source code directly compiles into native languages.
It does not provide low-level access to the programmer. It provide low-level access to the programmer.