We talked about the encoding of the Revit manifest format previously and reached the conclusion that the UTF-8 encoding should be used in both the XML/AddIn file declarations and the Save As file encoding options.
In this post, let us see how to load and parse the Revit manifest file programmatically. It is not necessary to do so most of times but it may quite be in other times.
The following sample code will list out the information about the first found AddIn in the specified manifest file:
try
{
XDocument xdoc = XDocument.Load(@"c:\temp\RevitAddinTest.addin");
string info = "AddIn Information:\n";
XElement node = xdoc.Root.Descendants("AddIn").First();
info += string.Format("\tType: {0}\n",node.Attribute("Type").Value);
foreach(XElement subNode in node.Elements())
{
info += string.Format("\t{0}: {1}\n", subNode.Name, subNode.Value);
}
MessageBox.Show(info, "Manifest Loading Test");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
If the specified manifest file looks like the following:
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Application">
<Assembly>C:\Temp\RevitAddin_δοκιμή.dll</Assembly>
<FullClassName>RevitAddinTest.ExtApp</FullClassName>
<ClientId>5ad0b84c-b30b-46fb-b9ff-f4bb4a90750a</ClientId>
<Name>RevitAddin δοκιμή</Name>
</AddIn>
</RevitAddIns>
the output will be:
By the way, if the file encoding (e.g. Unicode) does not match with the AddIn/XML file declaration (UTF-8 here), an exception with the following weird message will be thrown out:
In fact, the problem can be checked through a much simpler way, opening the .AddIn file with the Internet Explore (IExplore.EXE). And the message will be much more meaningful:
Revit Manifest Organizer of RevitAddinWidget does something similar to the above, loading and parsing Revit manifest files, check their integrities, detect duplicates, and a lot more.
Related posts:
Deploy & Install: Revit Application Addin Manifest
Deploy & Install: Revit Command Addin Manifest
Deploy & Install: Revit Addin Roaming Folders
Deploy & Install: The Registry of Revit 2011
Deploy & Install: The Registry of Revit 2012
Deploy & Install: Where Are Revit Products Installed
Deploy & Install: Manifest Navigator of RevitAddinWidget
Deploy & Install: RegEdit Launcher of RevitAddinWidget
Deploy & Install: Revit Locator of RevitAddinWidget
Deploy & Install: Manifest Encoding
Deploy & Install: Manifest Loading
Deploy & Install: Manifest ClientId
Deploy & Install: Manifest ClientId and AddinId
Deploy & Install: Manifest Integrity
Deploy & Install: Revit Manifest Organizer
Deploy & Install: Create New Of Revit Manifest Organizer
Deploy & Install: Check Integrity New Of Revit Manifest Organizer
Deploy & Install: Detect Duplicate New Of Revit Manifest Organizer
Deploy & Install: View Selected Of Revit Manifest Organizer
Deploy & Install: Edit Selected Of Revit Manifest Organizer
Deploy & Install: Merge Selected Of Revit Manifest Organizer
Deploy & Install: Dismantle Selected Of Revit Manifest Organizer
Deploy & Install: Copy/Move/Delete Selected Of Revit Manifest Organizer
Deploy & Install: Miscellaneous Of Revit Manifest Organizer
Deploy & Install: Create Revit Manifest Files Programmatically With C#
Deploy & Install: Programmatically Detect Windows Versions And Find Revit Addin Roaming Folders
Deploy & Install: Revit Addin Project Output And API Dependencies
Deploy & Install: Revit Addin Projects and Visual Studio Setup Custom Actions
Deploy & Install: Deploy Revit Manifest Files with C# Using Installer Custom Actions
Recent Comments