We have covered the manifest topic from various perspectives and demonstrated how to create, maintain, and manage them with various project wizards, item wizards, coders, and widgets.
In this post, let us look at the most basic but important factor about the Revit Manifest (.AddIn) files, encoding. As mentioned before, the manifest file is nothing more than an XML file and theoretically should support all the encodings that the XML format does.
As the documentation of the Encoding class of the .NET Framework lists out, there are 140 encodings or code pages, 36 of which are natively supported by the .NET Framework regardless of the underlying platform, more than half dozen are quite common, and the .NET Framework even provides standalone classes for them:
us-ascii
iso-8859-1
utf-7
utf-8
utf-16
utf-32
Windows-1252
But wait a moment, does the Revit Manifest really support all these encodings or code pages?
We do not really know, but we can do something to sort it out. Through checking all available SDK sample addins, it’s found that most of their manifest files use utf-8 encoding and a few use the ANSI or ASCII encoding by default through not specifying the xml encoding attribute at all:
AutoTagRooms.addin
CancelSave.addin
DeckProperties.addin
MaterialProperties.addin
ModelLines.addin
NewRoof.addin
PanelSchedule.addin
SpotDimension.addin
Here is the content of the SpotDimension.addin manifest file:
<?xml version="1.0"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>SpotDimension.dll</Assembly>
<ClientId>f11032af-f02b-47ad-9e19-330bb9c9988d</ClientId>
<FullClassName>Revit.SDK.Samples.SpotDimension.CS.Command</FullClassName>
<Text>Spot Dimension</Text>
<Description>Get all spot dimensions in all views and show their properties.</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
</AddIn>
</RevitAddIns>
Since all the samples have been there for long time, it can be safely inferred that both ANSI/ASCII and UTF-8 encoding are officially supported. However, does it mean that the ANSI/ASCII encoding have to be used for those manifest files that contain only ANSI characters?
Absolutely not as the other SDK manifest files do not seem to contain any non-ANSI characters either and the UTF-8 encoding works just fine.
Considering the fact that the path and name of the assembly file, the application name, the command text, and so on are all localizable, i.e. may contain any characters supported by the Windows, we’d better persist on the UTF-8 encoding for all manifest files. Otherwise, tricky problems may just happen.
For example, if an assembly with name RevitAddin_δοκιμή.dll exists and a manifest file is defined as follows and saved as with the ANSI encoding:
<?xml version="1.0"?>
<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>
when Revit starts up, it would complain about the Add-in Assembly Not Found:
Why? Because the non-ANSI characters have been interpreted as something else!
The following manifest file if saved with the UTF-8 encoding will work fine.
<?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>
So the good practice is to use the UTF-8 encoding all the time for the Revit manifest format and forget about the ANSI/ASCII encoding and any others.
RevitAddinWizard will follow this practice. Revit Manifest Organizer (specifically the Check Integrity button/feature) can help check the encoding and formatting issues and much more regarding Revit manifest files.
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