Reading Manifest Resources Programmatically

Reading Manifest Resources Programmatically


You need to obtain information about manifest resources.


Use the GetManifestResourceInfo and GetManifestResourceNames methods of the Assembly class:

	public static void DisplayManifestResourceInfo(string asmPath)
	    Assembly asm = Assembly.LoadFrom(asmPath);

	    foreach (string resName in asm.GetManifestResourceNames())
	        Console.WriteLine("Resource Name: " + resName);

	        ManifestResourceInfo mri = asm.GetManifestResourceInfo(resName);
	        Console.WriteLine("\rFileName: " + mri.FileName);
	        Console.WriteLine("\rResourceLocation: " + mri.ResourceLocation);
	        if (mri.ReferencedAssembly != null)
	            Console.WriteLine("\rReferencedAssembly: " +


To obtain a ManifestResourceInfo object or objects, you must first call the GetManifestResourceNames method on an Assembly object. This method returns an array of string objects, which contain the resource name. This resource name is then passed in to the GetManifestResourceInfo method to obtain the ManifestResourceInfo object. The ManifestResourceInfo object is what contains all the information about the manifest resource.

The ManifestResourceInfo.FileName property returns a fully qualified string describing the file that contains the manifest resource. This property will return an empty string if the resource is embedded in the same assembly on which the GetManifestResourceInfo was called.

The ManifestResourceInfo.ResourceLocation property returns all the ResourceLocation flags for this resource. These flags can be one or a combination of three values described in Figure.

ResourceLocation enumeration flags

Enumeration value



This resource exists in a separate assembly.


This resource exists in the manifest file.


This resource is an embedded resource, as opposed to a linked resource from a separate assembly.

The final property of use in the ManifestResourceInfo class is the ReferencedAssembly property. This property returns an Assembly object that contains the resource. This property returns null when the resource is embedded in the assembly on which this property was called.

See Also

See the "GetManifestResourceInfo Method" and "GetManifestResourceNames Method" topics in the MSDN documentation.

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows