How to use Application properties to enforce a correct version for your add-in

How to use Application properties to enforce a correct version for your add-in

Sometimes you need your add-in to operate only in the presence of a particular Update Release of Revit due to the presence of specific fixes or compatible APIs. The following sample code demonstrates a technique to determine if the Revit version is any Update Release after the initial known Revit release.

Code Region: Use VersionBuild to identify if your add-in is compatible

public void GetVersionInfo(Autodesk.Revit.ApplicationServices.Application app)
{ 
   // 20110309_2315 is the datecode of the initial release of Revit 2012 
   if (app.VersionNumber == "2012" && 
       String.Compare(app.VersionBuild, "20110309_2315") > 0)
   {
       TaskDialog.Show("Supported version", 
                      "This application supported in this version.");
   }
   else
   {
       TaskDialog dialog = new TaskDialog("Unsupported version.");
       dialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
       dialog.MainInstruction = "This application is only supported in Revit 2012 UR1 and later.";
       dialog.Show();
   }
}