Rohit Vipin Mathews
Rohit Vipin Mathews

Reputation: 11787

Difference between Metadata and Manifest

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

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

Q: So isn't Manifest a metadata?

Then what are its differences?

Upvotes: 12

Views: 34745

Answers (5)

Teju MB
Teju MB

Reputation: 1383

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.

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.

Upvotes: 15

Pranesh Archak
Pranesh Archak

Reputation: 71

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

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

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

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

enter image description here

Upvotes: 7

amit
amit

Reputation: 31

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

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.

Upvotes: 3

Rohit Vipin Mathews
Rohit Vipin Mathews

Reputation: 11787

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

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.aspx for more details.

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.aspx for more details.

you can read more about assembly manifest here

Metadata about the overall assembly and modules is called the manifest

Upvotes: 1

Rohit Vipin Mathews
Rohit Vipin Mathews

Reputation: 11787

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.

Upvotes: 0

Related Questions