managed and unmanaged code in c#
2010-12-21 11:29
316 查看
在看Unity plugin的时候,看到managed和unmanaged code,根据我所看的内容上下文,基本猜出来时啥意思。不过当时也就不求甚解那么过了。昨天看.net dll的一些内容的时候,重新看到了这个概念,于是google了一把。在一个论坛里面找到了一个比较全面科学的解释。
"Unmanaged code" is a new name for an
old concept. Unmanaged code stands for native machine code. Software is
typically written in some high-level language such as Pascal, C or C++.
These languages are translated into machine code (aka unmanaged code) by
the compiler and its companion tools (assembler, linker, librarian,
etc). The generated code runs natively on the host processor; that is,
the processor directly executes the code generated by the compiler. This
approach typically results in fastest code execution, but diagnosing
and recovery from errors might be easier in managed code.
Managed
code is a new name, but the concept also is pretty old. Today, "managed
code" typically stands for the system used by Microsoft .NET, but .NET
is just one example of a managed code system. The .NET system takes
source code in any of the supported languages (which include C, C++, C#,
Pascal, and many others), and translates it into code designed for a
virtual machine. The real processor cannot execute this code natively,
but it can execute a program which then in turn executes the virtual
machine's codes. The program that executes the virtual machine code is
known as the virtual machine. While potentially slower than native code
execution, the virtual machine can manage code (!) better than real
machines. For example, the virtual machine can supervise memory
allocation, automatically handle disposal of unused memory, and provide
many other services that a native (unmanaged) application typically must
explicitly provide. If the virtual machine does its job correctly, all
applications using this virtual machine are likely to benefit.
概念都是很老的,只不过两个新名词,类似pure java和jni。
"Unmanaged code" is a new name for an
old concept. Unmanaged code stands for native machine code. Software is
typically written in some high-level language such as Pascal, C or C++.
These languages are translated into machine code (aka unmanaged code) by
the compiler and its companion tools (assembler, linker, librarian,
etc). The generated code runs natively on the host processor; that is,
the processor directly executes the code generated by the compiler. This
approach typically results in fastest code execution, but diagnosing
and recovery from errors might be easier in managed code.
Managed
code is a new name, but the concept also is pretty old. Today, "managed
code" typically stands for the system used by Microsoft .NET, but .NET
is just one example of a managed code system. The .NET system takes
source code in any of the supported languages (which include C, C++, C#,
Pascal, and many others), and translates it into code designed for a
virtual machine. The real processor cannot execute this code natively,
but it can execute a program which then in turn executes the virtual
machine's codes. The program that executes the virtual machine code is
known as the virtual machine. While potentially slower than native code
execution, the virtual machine can manage code (!) better than real
machines. For example, the virtual machine can supervise memory
allocation, automatically handle disposal of unused memory, and provide
many other services that a native (unmanaged) application typically must
explicitly provide. If the virtual machine does its job correctly, all
applications using this virtual machine are likely to benefit.
概念都是很老的,只不过两个新名词,类似pure java和jni。
相关文章推荐
- How to handle exception in managed code and unmanaged code
- Handle unmanaged code in managed c# with the help of using statement
- What is Managed Code and Unmanaged Code in .Net Framework
- How to handle exception in managed code and unmanaged code
- Marshaling between Managed and Unmanaged Code
- c# - Create ServiceEndpoint in code and in config
- Sinking events from managed code in unmanaged C++
- How to call code behind method in JavaScript in C# and VS2010?
- 3D Terrain Visualisation in Managed DirectX 9 and C#(转载)
- keywords between managed c++ and c# in dotNet 2.0
- C++/CLI and C# VS COM and unmanaged Code
- Sample: Mixing Unmanaged C++, C++/CLI, and C# code
- Managed code and Unmanaged code
- Pro .NET 2.0 Code and Design Standards in C#
- Script and managed code in Silverlight
- How To Use the ODBC .NET Managed Provider in Visual C# .NET and Connection Strings
- C++ standard for managed and unmanaged code
- Marshaling between Managed and Unmanaged Code(转载)
- managed code and unmanaged code
- SpicIE: Writing IE 7 and IE 8 Plugins in Managed Code