Managed Code:
The term used to describe the code targeting the .NET Core runtime is
called managed code.
The code is executed by CLR (Common Language Runtime). In short, the code needs
.NET Core runtime to host and execute it. As it needs the .NET Core runtime for
its execution, it becomes platform-independent i.e., application/code can be
developed in Windows operating system and can be executed on Mac or Linux
operating system having .NET Core runtime and vice versa.
An assembly
is the binary unit that comprises the managed code. The code is compiled into
an intermediate language (MSIL/IL).
Managed
code makes use of the Common Language Runtime (CLR), which looks after the applications
by managing and handling memory and security, enabling cross-language
integration, code access security, and automatic lifetime control of objects.
It's
important to remember that the C# language can only be used to create
applications that run on the.NET Core runtime; it can't be used to create a
native COM server or an unmanaged C/C++ style
application. Consider
the following CLR execution model:
Unmanaged
Code:
Unmanaged
code is code that cannot be explicitly hosted by the.NET Core runtime and is executed
by the operating system directly.
Unmanaged codes
are those that do not run under the supervision of the CLR, and some languages
like C++ can be used to code them, for example, to access low-level operating
system functions.
A code
block that uses a pointer variable is known as unsafe or unmanaged code.
Unmanaged
code is executed using the operating system directly, which does not handle and
manage application security and memory.
Moreover,
code is compiled into the native language and provide low-level access.
That’s all
about managed vs unmanaged code in .NET Core. If you found this article helpful
share it with others. Let me know your queries and suggestions in the comment
section below. Do subscribe to my site and channel as I don’t want you to miss any
update.
Moreover,
you can also contact me and share your queries on Instagram, Facebook or
Twitter. I would love to provide a solution to your issues.
Stay tuned
and strive to learn. Keep learning, keep growing!
0 Comments