views:

31

answers:

2

I am looking for a way to have the hosting website parse out the [appname].manifest file to pull out the application name, version, and icon if available. This way I can put it into a control for easy deployment. Are there any framework calls that will assist me in parsing out the manifest file?

The files I am looking for are [appname].application and/or [appname].manifest

A: 

System.Diagnostics.FileVersionInfo will do most of the heavy lifting for you. It'll extract meta-data from a file to determine the assembly's Product Name & Version. As for the Icon, that's a different story, but at least this is a start for you:

Update:

Also using System.Reflection.Assembly you can call GetManifestResourceInfo(string), GetManifestResourceNames(), and GetManifestResourceStream(string) to access an assembly’s resources (for the Icon).

Aren
thank you; however, I am looking for the parses that will parse the *.application and/or the *.manifest xml based files. In a clickonce application the xml application and manifest files are now the same as the binary encoded ones.
AdamSane
A: 

You can get most of the info you want using the System.Deployment.Application.InPlaceHostingManager class - don't be fooled by the name, it is primarily for browser-hosted ClickOnce apps, but also works for standalone ClickOnce apps. Once you initialise an instance and pass it the URL to the .application file, you can call GetManifestAsync() - in the event handler for GetManifestCompleted, you can get the application name and version:

void iphm_GetManifestCompleted(object sender, GetManifestCompletedEventArgs e) {
    Console.WriteLine("Application name: {0}", e.ApplicationIdentity);
    Console.WriteLine("Application version: {0}", e.Version);
}

The icon is usually referenced in the application manifest (.application is the deployment manifest) - the app manifest can be accessed using InPlaceHostingManager; in the above example, you'd get the value from e.ApplicationManifest which would give you an XmlReader to play with.

Probably best to study the relevant XML schema(s) and then find the icon using XQuery.

Bradley Smith