I am using Assembly.GetEntryAssembly()
... in my C# code to get the version of the application. It runs fine but when I try it in NUnit it returns NULL
. In the MSDN it states that it can return NULL
when called from unmanaged code.
我用Assembly.GetEntryAssembly()……在我的c#代码中获取应用程序的版本。它运行良好,但当我在NUnit中尝试时,它返回NULL。在MSDN中,它声明在从非托管代码调用时可以返回NULL。
What is managed or unmanaged code? I do not get it.
什么是托管或非托管代码?我不明白。
12 个解决方案
#1
66
Here is some text from MSDN about unmanaged code.
下面是MSDN关于非托管代码的一些文本。
Some library code needs to call into unmanaged code (for example, native code APIs, such as Win32). Because this means going outside the security perimeter for managed code, due caution is required.
一些库代码需要调用非托管代码(例如,本地代码api,如Win32)。因为这意味着要超出托管代码的安全范围,所以需要格外小心。
Here is some other complimentary explication about Managed code:
以下是一些关于托管代码的补充说明:
- Code that is executed by the CLR.
- 由CLR执行的代码。
- Code that targets the common language runtime, the foundation of the .NET Framework, is known as managed code.
- 针对公共语言运行时的代码,即。net框架的基础,被称为托管代码。
- 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.
- 托管代码为CLR提供必要的元数据,以提供诸如内存管理、跨语言集成、代码访问安全性和对象的自动生命周期控制等服务。所有基于IL的代码都作为托管代码执行。
- Code that executes under the CLI execution environment.
- 在CLI执行环境下执行的代码。
For your problem:
对于你的问题:
I think it's because NUnit execute your code for UnitTesting and might have some part of it that is unmanaged. But I am not sure about it, so do not take this for gold. I am sure someone will be able to give you more information about it. Hope it helps!
我认为这是因为NUnit执行UnitTesting的代码,它的某些部分可能是不受管理的。但我不确定,所以不要把这当成黄金。我相信有人会给你更多的信息。希望它可以帮助!
#2
162
This is a good article about the subject.
这是一篇关于这个主题的好文章。
Crib sheet:
床单:
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.
托管代码不是编译为机器码,而是编译为一种中间语言,它由机器上的某些服务解释和执行,因此在一个(希望如此)安全的框架中运行,该框架为您处理像内存和线程这样的危险事物。在现代的用法中,这通常意味着。net,但不需要。
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
非托管代码编译为机器代码,因此由操作系统直接执行。因此,它有能力做破坏性的/强大的事情,而托管代码没有。这是所有东西都用来工作的方式,所以它通常与旧的东西相关联,比如。dll
Native code is often synonymous with Unmanaged, but is not identical.
本机代码通常是Unmanaged的同义词,但并不完全相同。
#3
61
When you think of unmanaged, think machine-specific, machine-level code. Like x86 assembly language. Unmanaged (native) code is compiled and linked to run directly on the processor it was designed for, excluding all the OS stuff for the moment. It's not portable, but it is fast. Very simple, stripped down code.
当您想到非托管的、特定于机器的、机器级的代码时。像x86汇编语言。非托管(本机)代码被编译并链接到它设计的处理器上直接运行,暂时不包含所有OS内容。它不是便携式的,但速度很快。非常简单,简化代码。
Managed code is everything from Java to old Interpretive BASIC, or anything that runs under .NET. Managed code typically is compiled to an intermediate level P-Code or byte code set of instructions. These are not machine-specific instructions, although they look similar to assembly language. Managed code insulates the program from the machine it's running on, and creates a secure boundary in which all memory is allocated indirectly, and generally speaking, you don't have direct access to machine resources like ports, memory address space, the stack, etc. The idea is to run in a more secure environment.
托管代码是所有的东西,从Java到旧的解释性BASIC,或者任何在。net下运行的东西。托管代码通常编译为中级水平的P-Code或指令的字节码集。这些不是特定于机器的指令,尽管它们看起来类似于汇编语言。托管代码使程序的机器上运行,并创建一个安全边界的所有内存分配间接的,一般来说,你没有直接访问机器资源(如港口、内存地址空间,堆栈等。这样做是为了在更安全的环境中运行。
To convert from a managed variable, say, to an unmanaged one, you have to get to the actual object itself. It's probably wrapped or boxed in some additional packaging. UNmanaged variables (like an 'int', say) - on a 32 bit machine - takes exactly 4 bytes. There is no overhead or additional packaging. The process of going from managed to unmanaged code - and back again - is called "marshaling". It allows your programs to cross the boundary.
要从托管变量转换为非托管变量,您必须访问实际的对象本身。它很可能是用其他的包装包装或盒装的。非托管变量(比如“int”)——在32位机器上——只需要4个字节。没有开销或额外的打包。从托管代码到非托管代码再返回的过程称为“封送处理”。它允许你的程序跨越边界。
#4
23
In as few words as possible:
尽量少说几句话:
- managed code = .NET programs
- 托管代码= .NET程序。
- unmanaged code = "normal" programs
- 非托管代码=“正常”程序
#5
5
Basically unmanaged code is code which does not run under the .NET CLR (aka not VB.NET, C#, etc.). My guess is that NUnit has a runner/wrapper which is not .NET code (aka C++).
基本上非托管代码是在。net CLR(不是VB)下运行的代码。净、c#等)。我猜NUnit有一个运行器/包装器,它不是。net代码(即c++)。
#6
4
NUnit loads the unit tests in a seperate AppDomain, and I assume the entry point is not being called (probably not needed), hence the entry assembly is null.
NUnit在一个独立的AppDomain中加载单元测试,我假设没有调用入口点(可能不需要),因此入口程序集为null。
#7
4
Managed Code:
Code that runs under a "contract of cooperation" with the common language runtime. Managed code must supply the metadata necessary for the runtime to provide services such as memory management, cross-language integration, code access security, and automatic lifetime control of objects. All code based on Microsoft intermediate language (MSIL) executes as managed code.托管代码:在与公共语言运行时的“合作契约”下运行的代码。托管代码必须提供运行时所需的元数据,以提供诸如内存管理、跨语言集成、代码访问安全性和对象的自动生命周期控制等服务。所有基于微软中间语言(MSIL)的代码都作为托管代码执行。
Un-Managed Code:
Code that is created without regard for the conventions and requirements of the common language runtime. Unmanaged code executes in the common language runtime environment with minimal services (for example, no garbage collection, limited debugging, and so on).非托管代码:不考虑公共语言运行时的约定和需求而创建的代码。非托管代码在公共语言运行时环境中以最少的服务执行(例如,没有垃圾收集、有限的调试等等)。
Reference: http://www.dotnetspider.com/forum/11612-difference-between-managed-and-unmanaged-code.aspx
参考:http://www.dotnetspider.com/forum/11612-difference-between-managed-and-unmanaged-code.aspx
#8
3
Managed code runs inside the environment of CLR i.e. .NET runtime.In short all IL are managed code.But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.
托管代码在CLR(即。net运行时)的环境中运行。简而言之,所有的IL都是托管代码。但是,如果您使用的是第三方软件VB6或VB6或vc++组件,那么它们是非托管代码,因为. net运行时(CLR)无法控制语言的源代码执行。
#9
2
Managed Code :- Code which MSIL (intermediate language) form is developed after the language compiler compilation and directly executed by CLR
called managed code. eg:- All 61 language code supported by .net framework
托管代码:- MSIL(中间语言)形式的代码,是在语言编译器编译后开发出来的,由CLR直接执行,称为托管代码。- .net框架支持的所有61种语言代码
Unmanaged Code:- code that developed before .net
for which MSIL form is not available and it is executed by CLR
directly rather CLR
will redirect to operating system this is known as unmanaged code.
非托管代码:-在。net之前开发的代码,其中MSIL形式不可用,并且由CLR直接执行,而CLR将重定向到操作系统,这就是所谓的非托管代码。
eg:-COM,Win32 APIs
呈爆炸式,Win32 api
#10
1
- Managed Code: code written in .NET language like C#, VB.NET.
- 托管代码:用。net语言编写的代码,如c#、VB.NET。
- UnManaged Code: code not written in .NET language and MSIL does not understand what it is and can not run under CLR; like third-party controls we used in our .NET applications which is not created in .NET languages.
- 非托管代码:没有使用。net语言编写的代码,MSIL不理解它是什么,不能在CLR下运行;就像我们在。net程序中使用的第三方控件,它不是在。net语言中创建的。
#11
1
First of all understand this, before .NET framework
, Microsoft
were providing the stand-alone products like MFC (Visual C++), VB, FoxPro
etc.
首先要明白的是,在。net框架出现之前,微软一直在提供MFC (Visual c++)、VB、FoxPro等独立产品。
In 2002, Microsoft combined its products and made .NET framework. Now there is a difference between how code was executed before and how code is managed and executed in .NET framework. Microsoft introduced concept of CLR
with .NET framework which compiles the code coming from any supported lanugague of .NET framework and provide additional functionalities like memory mangement, garbage collection
etc. But, such CLR features weren't available directly before.
2002年,微软将其产品和。net框架结合起来。现在,在。net框架中,代码的执行方式和代码的管理和执行方式是不同的。微软引入了。net框架的CLR概念,它编译了来自于。net框架的任何支持的lanugague的代码,并提供了一些附加的功能,比如内存管理、垃圾收集等等,但是这些CLR特性在之前是无法得到的。
So if you are creating library/code in .NET framework (compiled with CLR) then that is called
Managed code
. You can use this library further in other .NET application/project, and there too, CLR will understand how it was compiled before, and that's why it remains your manage code.因此,如果您正在. net framework中创建库/代码(使用CLR编译),那么这就是托管代码。您可以在其他. net应用程序/项目中进一步使用这个库,CLR也将了解它以前是如何编译的,这就是为什么它仍然是您的管理代码。
OTOH if you want to use the libraries that were written prior to .NET framework then you can do with certain limitations, but remember, since CLR wasn't there at that time, so now, CLR won't understand and compile this code again. And this will be called unmanaged code
. Please note that, libraries/assembilies created by some third party to provide certain features/tool may also be considered as unmanage code if is not CLR compatiblie.
OTOH如果你想使用在。net框架之前编写的库,那么你可以使用一定的限制,但是请记住,因为CLR当时并不存在,所以CLR现在不会再理解和编译这段代码了。这将被称为非托管代码。请注意,如果不是CLR兼容程序,由第三方创建的用于提供某些特性/工具的库/汇编程序也可能被认为是不管理的代码。
In laymen terms, Manage code is something which your CLR understands and can compile it on its own for further execution. In .NET framework, (from any language thats work on .NET framework) When code goes to CLR then code supply some meta data information, so that CLR can provide you features specified here. Few of them are Garbage collection, Performance improvements, cross-language integration, memory management
etc.
用外行的话说,管理代码是您的CLR能够理解的,并且可以自己编译它以进行进一步的执行。在。net框架中(来自任何在。net框架中工作的语言),当代码进入CLR时,代码提供一些元数据信息,这样CLR就可以为您提供这里指定的特性。其中很少有垃圾收集、性能改进、跨语言集成、内存管理等。
OTOH, unmanged code is something specific to machine and ready to use, no need to process it further.
OTOH, unmanged代码是特定于机器的,可以使用,不需要进一步处理。
#12
0
From Pro C# 5 and the .NET 4.5 Framework:
来自Pro c# 5和。net 4.5框架:
Managed vs. Unmanaged Code: Perhaps the most important point to understand about the C# language is that it can produce code that can execute only within the .NET runtime (you could never use C# to build a native COM server or an unmanaged C/C++ application). Officially speaking, the term used to describe the code targeting the .NET runtime is managed code. The binary unit that contains the managed code is termed an assembly (more details on assemblies in just a bit). Conversely, code that cannot be directly hosted by the .NET runtime is termed unmanaged code.
托管代码与非托管代码:关于c#语言,最重要的一点是,它可以生成只能在. net运行时执行的代码(您永远不能使用c#来构建本机COM服务器或非托管的C/ c++应用程序)。正式地说,用于描述针对。net运行时的代码的术语是托管代码。包含托管代码的二进制单元被称为程序集(关于程序集的更多详细信息请参阅)。相反,不能由. net运行时直接托管的代码被称为非托管代码。
#1
66
Here is some text from MSDN about unmanaged code.
下面是MSDN关于非托管代码的一些文本。
Some library code needs to call into unmanaged code (for example, native code APIs, such as Win32). Because this means going outside the security perimeter for managed code, due caution is required.
一些库代码需要调用非托管代码(例如,本地代码api,如Win32)。因为这意味着要超出托管代码的安全范围,所以需要格外小心。
Here is some other complimentary explication about Managed code:
以下是一些关于托管代码的补充说明:
- Code that is executed by the CLR.
- 由CLR执行的代码。
- Code that targets the common language runtime, the foundation of the .NET Framework, is known as managed code.
- 针对公共语言运行时的代码,即。net框架的基础,被称为托管代码。
- 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.
- 托管代码为CLR提供必要的元数据,以提供诸如内存管理、跨语言集成、代码访问安全性和对象的自动生命周期控制等服务。所有基于IL的代码都作为托管代码执行。
- Code that executes under the CLI execution environment.
- 在CLI执行环境下执行的代码。
For your problem:
对于你的问题:
I think it's because NUnit execute your code for UnitTesting and might have some part of it that is unmanaged. But I am not sure about it, so do not take this for gold. I am sure someone will be able to give you more information about it. Hope it helps!
我认为这是因为NUnit执行UnitTesting的代码,它的某些部分可能是不受管理的。但我不确定,所以不要把这当成黄金。我相信有人会给你更多的信息。希望它可以帮助!
#2
162
This is a good article about the subject.
这是一篇关于这个主题的好文章。
Crib sheet:
床单:
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.
托管代码不是编译为机器码,而是编译为一种中间语言,它由机器上的某些服务解释和执行,因此在一个(希望如此)安全的框架中运行,该框架为您处理像内存和线程这样的危险事物。在现代的用法中,这通常意味着。net,但不需要。
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
非托管代码编译为机器代码,因此由操作系统直接执行。因此,它有能力做破坏性的/强大的事情,而托管代码没有。这是所有东西都用来工作的方式,所以它通常与旧的东西相关联,比如。dll
Native code is often synonymous with Unmanaged, but is not identical.
本机代码通常是Unmanaged的同义词,但并不完全相同。
#3
61
When you think of unmanaged, think machine-specific, machine-level code. Like x86 assembly language. Unmanaged (native) code is compiled and linked to run directly on the processor it was designed for, excluding all the OS stuff for the moment. It's not portable, but it is fast. Very simple, stripped down code.
当您想到非托管的、特定于机器的、机器级的代码时。像x86汇编语言。非托管(本机)代码被编译并链接到它设计的处理器上直接运行,暂时不包含所有OS内容。它不是便携式的,但速度很快。非常简单,简化代码。
Managed code is everything from Java to old Interpretive BASIC, or anything that runs under .NET. Managed code typically is compiled to an intermediate level P-Code or byte code set of instructions. These are not machine-specific instructions, although they look similar to assembly language. Managed code insulates the program from the machine it's running on, and creates a secure boundary in which all memory is allocated indirectly, and generally speaking, you don't have direct access to machine resources like ports, memory address space, the stack, etc. The idea is to run in a more secure environment.
托管代码是所有的东西,从Java到旧的解释性BASIC,或者任何在。net下运行的东西。托管代码通常编译为中级水平的P-Code或指令的字节码集。这些不是特定于机器的指令,尽管它们看起来类似于汇编语言。托管代码使程序的机器上运行,并创建一个安全边界的所有内存分配间接的,一般来说,你没有直接访问机器资源(如港口、内存地址空间,堆栈等。这样做是为了在更安全的环境中运行。
To convert from a managed variable, say, to an unmanaged one, you have to get to the actual object itself. It's probably wrapped or boxed in some additional packaging. UNmanaged variables (like an 'int', say) - on a 32 bit machine - takes exactly 4 bytes. There is no overhead or additional packaging. The process of going from managed to unmanaged code - and back again - is called "marshaling". It allows your programs to cross the boundary.
要从托管变量转换为非托管变量,您必须访问实际的对象本身。它很可能是用其他的包装包装或盒装的。非托管变量(比如“int”)——在32位机器上——只需要4个字节。没有开销或额外的打包。从托管代码到非托管代码再返回的过程称为“封送处理”。它允许你的程序跨越边界。
#4
23
In as few words as possible:
尽量少说几句话:
- managed code = .NET programs
- 托管代码= .NET程序。
- unmanaged code = "normal" programs
- 非托管代码=“正常”程序
#5
5
Basically unmanaged code is code which does not run under the .NET CLR (aka not VB.NET, C#, etc.). My guess is that NUnit has a runner/wrapper which is not .NET code (aka C++).
基本上非托管代码是在。net CLR(不是VB)下运行的代码。净、c#等)。我猜NUnit有一个运行器/包装器,它不是。net代码(即c++)。
#6
4
NUnit loads the unit tests in a seperate AppDomain, and I assume the entry point is not being called (probably not needed), hence the entry assembly is null.
NUnit在一个独立的AppDomain中加载单元测试,我假设没有调用入口点(可能不需要),因此入口程序集为null。
#7
4
Managed Code:
Code that runs under a "contract of cooperation" with the common language runtime. Managed code must supply the metadata necessary for the runtime to provide services such as memory management, cross-language integration, code access security, and automatic lifetime control of objects. All code based on Microsoft intermediate language (MSIL) executes as managed code.托管代码:在与公共语言运行时的“合作契约”下运行的代码。托管代码必须提供运行时所需的元数据,以提供诸如内存管理、跨语言集成、代码访问安全性和对象的自动生命周期控制等服务。所有基于微软中间语言(MSIL)的代码都作为托管代码执行。
Un-Managed Code:
Code that is created without regard for the conventions and requirements of the common language runtime. Unmanaged code executes in the common language runtime environment with minimal services (for example, no garbage collection, limited debugging, and so on).非托管代码:不考虑公共语言运行时的约定和需求而创建的代码。非托管代码在公共语言运行时环境中以最少的服务执行(例如,没有垃圾收集、有限的调试等等)。
Reference: http://www.dotnetspider.com/forum/11612-difference-between-managed-and-unmanaged-code.aspx
参考:http://www.dotnetspider.com/forum/11612-difference-between-managed-and-unmanaged-code.aspx
#8
3
Managed code runs inside the environment of CLR i.e. .NET runtime.In short all IL are managed code.But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.
托管代码在CLR(即。net运行时)的环境中运行。简而言之,所有的IL都是托管代码。但是,如果您使用的是第三方软件VB6或VB6或vc++组件,那么它们是非托管代码,因为. net运行时(CLR)无法控制语言的源代码执行。
#9
2
Managed Code :- Code which MSIL (intermediate language) form is developed after the language compiler compilation and directly executed by CLR
called managed code. eg:- All 61 language code supported by .net framework
托管代码:- MSIL(中间语言)形式的代码,是在语言编译器编译后开发出来的,由CLR直接执行,称为托管代码。- .net框架支持的所有61种语言代码
Unmanaged Code:- code that developed before .net
for which MSIL form is not available and it is executed by CLR
directly rather CLR
will redirect to operating system this is known as unmanaged code.
非托管代码:-在。net之前开发的代码,其中MSIL形式不可用,并且由CLR直接执行,而CLR将重定向到操作系统,这就是所谓的非托管代码。
eg:-COM,Win32 APIs
呈爆炸式,Win32 api
#10
1
- Managed Code: code written in .NET language like C#, VB.NET.
- 托管代码:用。net语言编写的代码,如c#、VB.NET。
- UnManaged Code: code not written in .NET language and MSIL does not understand what it is and can not run under CLR; like third-party controls we used in our .NET applications which is not created in .NET languages.
- 非托管代码:没有使用。net语言编写的代码,MSIL不理解它是什么,不能在CLR下运行;就像我们在。net程序中使用的第三方控件,它不是在。net语言中创建的。
#11
1
First of all understand this, before .NET framework
, Microsoft
were providing the stand-alone products like MFC (Visual C++), VB, FoxPro
etc.
首先要明白的是,在。net框架出现之前,微软一直在提供MFC (Visual c++)、VB、FoxPro等独立产品。
In 2002, Microsoft combined its products and made .NET framework. Now there is a difference between how code was executed before and how code is managed and executed in .NET framework. Microsoft introduced concept of CLR
with .NET framework which compiles the code coming from any supported lanugague of .NET framework and provide additional functionalities like memory mangement, garbage collection
etc. But, such CLR features weren't available directly before.
2002年,微软将其产品和。net框架结合起来。现在,在。net框架中,代码的执行方式和代码的管理和执行方式是不同的。微软引入了。net框架的CLR概念,它编译了来自于。net框架的任何支持的lanugague的代码,并提供了一些附加的功能,比如内存管理、垃圾收集等等,但是这些CLR特性在之前是无法得到的。
So if you are creating library/code in .NET framework (compiled with CLR) then that is called
Managed code
. You can use this library further in other .NET application/project, and there too, CLR will understand how it was compiled before, and that's why it remains your manage code.因此,如果您正在. net framework中创建库/代码(使用CLR编译),那么这就是托管代码。您可以在其他. net应用程序/项目中进一步使用这个库,CLR也将了解它以前是如何编译的,这就是为什么它仍然是您的管理代码。
OTOH if you want to use the libraries that were written prior to .NET framework then you can do with certain limitations, but remember, since CLR wasn't there at that time, so now, CLR won't understand and compile this code again. And this will be called unmanaged code
. Please note that, libraries/assembilies created by some third party to provide certain features/tool may also be considered as unmanage code if is not CLR compatiblie.
OTOH如果你想使用在。net框架之前编写的库,那么你可以使用一定的限制,但是请记住,因为CLR当时并不存在,所以CLR现在不会再理解和编译这段代码了。这将被称为非托管代码。请注意,如果不是CLR兼容程序,由第三方创建的用于提供某些特性/工具的库/汇编程序也可能被认为是不管理的代码。
In laymen terms, Manage code is something which your CLR understands and can compile it on its own for further execution. In .NET framework, (from any language thats work on .NET framework) When code goes to CLR then code supply some meta data information, so that CLR can provide you features specified here. Few of them are Garbage collection, Performance improvements, cross-language integration, memory management
etc.
用外行的话说,管理代码是您的CLR能够理解的,并且可以自己编译它以进行进一步的执行。在。net框架中(来自任何在。net框架中工作的语言),当代码进入CLR时,代码提供一些元数据信息,这样CLR就可以为您提供这里指定的特性。其中很少有垃圾收集、性能改进、跨语言集成、内存管理等。
OTOH, unmanged code is something specific to machine and ready to use, no need to process it further.
OTOH, unmanged代码是特定于机器的,可以使用,不需要进一步处理。
#12
0
From Pro C# 5 and the .NET 4.5 Framework:
来自Pro c# 5和。net 4.5框架:
Managed vs. Unmanaged Code: Perhaps the most important point to understand about the C# language is that it can produce code that can execute only within the .NET runtime (you could never use C# to build a native COM server or an unmanaged C/C++ application). Officially speaking, the term used to describe the code targeting the .NET runtime is managed code. The binary unit that contains the managed code is termed an assembly (more details on assemblies in just a bit). Conversely, code that cannot be directly hosted by the .NET runtime is termed unmanaged code.
托管代码与非托管代码:关于c#语言,最重要的一点是,它可以生成只能在. net运行时执行的代码(您永远不能使用c#来构建本机COM服务器或非托管的C/ c++应用程序)。正式地说,用于描述针对。net运行时的代码的术语是托管代码。包含托管代码的二进制单元被称为程序集(关于程序集的更多详细信息请参阅)。相反,不能由. net运行时直接托管的代码被称为非托管代码。