.net 元数据和清单的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9407346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:15:56  来源:igfitidea点击:

Difference between Metadata and Manifest

.netmetadatamanifest

提问by Rohit Vipin Mathews

I'm learning .NET framework and been reading through Metadataand Manifest.

我正在学习 .NET 框架并一直在阅读MetadataManifest

"Metadata is data about data and Manifest is data about assembly!!"

“元数据是关于数据的数据,而清单是关于组装的数据!!”

Q: So isn't Manifest a metadata?

问:那么 Manifest 不是元数据吗?

Then what are its differences?

那么它的区别是什么呢?

回答by Teju MB

Manifest maintains the information about the assemblies like version, name locale and an optional strong name that uniquely identifying the assembly. This manifest information is used by the CLR. The manifest also contains the security demands to verify this assembly. It also contains the names and hashes of all the files that make up the assembly. The .NET assembly manifest contains a cryptographic hash of different modules in the assembly. And when the assembly is loaded, the CLR recalculates the hash of the modules at hand, and compares it with the embedded hash. If the hash generated at runtime is different from that found in the manifest, .NET refuses to load the assembly and throws an exception.

清单维护有关程序集的信息,如版本、名称区域设置和唯一标识程序集的可选强名称。此清单信息由 CLR 使用。清单还包含验证此程序集的安全要求。它还包含组成程序集的所有文件的名称和哈希值。.NET 程序集清单包含程序集中不同模块的加密哈希。当程序集被加载时,CLR 会重新计算手头模块的哈希值,并将其与嵌入的哈希值进行比较。如果运行时生成的散列与清单中的散列不同,.NET 将拒绝加载程序集并引发异常。

Metadata means data about the data. Metadata yields the types available in that assembly, viz. classes, interfaces, enums, structs, etc., and their containing namespaces, the name of each type, its visibility/scope, its base class, the interfaces it implemented, its methods and their scope, and each method's parameters, type's properties, and so on. The assembly metadata is generated by the high-level compilers automatically from the source files. The compiler embeds the metadata in the target output file, a dll, an .exe or a .netmodule in the case of multi-module assembly.

元数据是指关于数据的数据。元数据产生该程序集中可用的类型,即。类、接口、枚举、结构等,以及它们包含的命名空间、每个类型的名称、它的可见性/范围、它的基类、它实现的接口、它的方法和它们的范围,以及每个方法的参数、类型的属性、等等。程序集元数据由高级编译器从源文件自动生成。在多模块程序集的情况下,编译器将元数据嵌入到目标输出文件、dll、.exe 或 .netmodule 中。

回答by Pranesh Archak

Here is the simplest answer.

这是最简单的答案。

Assembly : One or more Files comprising your program. Usually Exe or dll or a combination of these and some other set of files

程序集:组成您的程序的一个或多个文件。通常是 Exe 或 dll 或这些和其他一些文件集的组合

MetaData : Contains both 1)Assembly Metadata 2) Type Metadata.

元数据:包含 1) 程序集元数据 2) 类型元数据。

1)Assembly Metadata is also known as MANIFEST, It contains Assembly's Name, Versions, Culture, Strong Name Info, Referenced assembly info...etc.

1)程序集元数据也称为清单,它包含程序集的名称、版本、文化、强名称信息、引用的程序集信息...等。

2)Type Metadata is the data types exported and Methods of the assembly.

2)Type Metadata 是导出的数据类型和程序集的方法。

enter image description here

在此处输入图片说明

回答by amit

Manifest: it store the information (like name of assemblies, version etc) about the assemblies which is required by CLR to load the assemblies.

清单:它存储有关 CLR 加载程序集所需的程序集的信息(如程序集名称、版本等)。

Metadata : It store the detail of assemblies like method name, it's members etc.

元数据:它存储程序集的详细信息,如方法名称、成员等。

Both the files are generated automatically by the compiler when converting the code to MSIL.

这两个文件都是在将代码转换为 MSIL 时由编译器自动生成的。

回答by Rohit Vipin Mathews

From "Programming .NET Components, Second Edition" By Juval Lowy published by O'ReillyPage 39 first paragraph:

来自O'Reilly 出版的 Juval Lowy 的“Programming .NET Components, Second Edition”第 39 页第一段:

Metadata:

元数据:

Metadata is the complete way of describing what is in a .NET assembly. Digging into the metadata yields the types available in that assembly, viz. classes, interfaces, enums, structs, etc., and their containing namespaces, the name of each type, its visibility/scope, its base class, the interfaces it implemented, its methods and their scope, and each method's parameters, type's properties, and so on. The assembly metada is generated by the high-level compilers automatically from the source files. The compiler embeds the metadata in the target output file, a dll, an .exe or a .netmodule in the case of multi-module assembly. In the case of a multimodule assembly ever module that contains IL must have the metadata embeded in it to describe the types in that module. Every compiler targeted for the .NET CLR is required to generate and embed the metadata in the output file, and that metadata must be in a standard format. .NET Reflection extensively uses the metadata information to know the type information dynamically.

Metadata is additional information in a managed assembly describing things like types, type names, method names, etc (basically, the information that you can retrieve from the Reflection services). See http://msdn2.microsoft.com/en-us/library/ms404430.aspxfor more details.

元数据是描述 .NET 程序集中内容的完整方式。深入研究元数据会产生该程序集中可用的类型,即。类、接口、枚举、结构等,以及它们包含的命名空间、每个类型的名称、它的可见性/范围、它的基类、它实现的接口、它的方法和它们的范围,以及每个方法的参数、类型的属性、等等。汇编元数据由高级编译器从源文件中自动生成。在多模块程序集的情况下,编译器将元数据嵌入到目标输出文件、dll、.exe 或 .netmodule 中。在多模块程序集的情况下,包含 IL 的模块必须嵌入元数据以描述该模块中的类型。每个针对 . NET CLR 需要生成元数据并将其嵌入到输出文件中,并且该元数据必须采用标准格式。.NET Reflection 广泛使用元数据信息来动态了解类型信息。

元数据是托管程序集中的附加信息,用于描述类型、类型名称、方法名称等(基本上,您可以从反射服务中检索的信息)。有关更多详细信息,请参阅http://msdn2.microsoft.com/en-us/library/ms404430.aspx

Assembly Manifest:

组装清单:

Metadata describes the contents in an assembly, whereas the manifest describes the assembly itself, providing the logical attributes shared by all the modules and all components in the assembly. The manifest contains the assembly name, version number, locale and an optional strong name that uniquely identifying the assembly. This manifest information is used by the CLR. The manifest also contains the security demands to verify this assembly. It also contains the names and hashes of all the files that make up the assembly. The .NET assembly manifest contains a cryptographic hash of different modules in the assembly. And when the assembly is loaded, the CLR recalculates the hash of the modules at hand, and compares it with the embeded hash. If the hash generated at runtime is different from that found in the manifest, .NET refuses to load the assembly and throws an exception. This is different from COM, under COM it is possible to swap an original DLL or EXE file with another, which have same Type Libraries/Interfaces and cause damage to the system, by running malacious code. The manifest is also generated automatically by the high-level compiler from the source files of all modules in the assembly. Manifest is embeded to only one physical file and only once since it is common for all the modules in an assembly, whereas the metadata needs to be embeded all the modules. The .NET CLR compatible compilers must generate the manifest and it should be in the standard format. Using the manifest .NET captures information about other referenced assemblies. This ensures version compatibility, and the assembly gets to interact with the exact trusted set of other assemblies it expects. The manifest contains every referenced assembly name, its public key (if a strong name is available), its version number, and locale. While running this assembly, .NET guarantees that only these specific assemblies are used, and that only compatible versions are loaded.

"Manifest" is a pretty overloaded term. In .NET, an "assembly manifest" is some metadata in an assembly describing versioning stuff. See here http://msdn2.microsoft.com/en-us/library/1w45z383.aspxfor more details.

元数据描述程序集中的内容,而清单描述程序集本身,提供程序集中所有模块和所有组件共享的逻辑属性。清单包含程序集名称、版本号、区域设置和唯一标识程序集的可选强名称。此清单信息由 CLR 使用。清单还包含验证此程序集的安全要求。它还包含组成程序集的所有文件的名称和哈希值。.NET 程序集清单包含程序集中不同模块的加密哈希。当程序集被加载时,CLR 会重新计算手头模块的哈希值,并将其与嵌入的哈希值进行比较。如果运行时生成的散列与清单中的散列不同,. NET 拒绝加载程序集并引发异常。这与 COM 不同,在 COM 下,可以通过运行恶意代码将原始 DLL 或 EXE 文件与另一个具有相同类型库/接口并导致系统损坏的文件交换。清单也是由高级编译器根据程序集中所有模块的源文件自动生成的。Manifest 只嵌入到一个物理文件中,并且只嵌入一次,因为它对程序集中的所有模块都是通用的,而元数据需要嵌入所有模块。.NET CLR 兼容编译器必须生成清单并且它应该是标准格式。使用清单 .NET 捕获有关其他引用程序集的信息。这确保了版本兼容性,并且程序集可以与它期望的其他程序集的确切可信集进行交互。清单包含每个引用的程序集名称、它的公钥(如果强名称可用)、它的版本号和区域设置。在运行这个程序集时,.NET 保证只使用这些特定的程序集,并且只加载兼容的版本。

“清单”是一个非常重载的术语。在 .NET 中,“程序集清单”是程序集中描述版本控制内容的一些元数据。有关 更多详细信息,请参见此处http://msdn2.microsoft.com/en-us/library/1w45z383.aspx

you can read more about assembly manifest here

您可以在此处阅读有关程序集清单的更多信息

Metadata about the overall assembly and modules is called the manifest

有关整个程序集和模块的元数据称为清单

回答by Rohit Vipin Mathews

Metadata describes the contents in an assembly, whereas the manifest describes the assembly itself, providing the logical attributes shared by all the modules and all components in the assembly. The manifest contains the assembly name, version number, locale and an optional strong name that uniquely identifying the assembly.

元数据描述程序集中的内容,而清单描述程序集本身,提供程序集中所有模块和所有组件共享的逻辑属性。清单包含程序集名称、版本号、区域设置和唯一标识程序集的可选强名称。