Solution to Multi-Dependency Update Issues in Revit Add-in Manager
I am using this open source project related to Add-in Manager:
Project Logic
- The project adopts a method of loading the
RevitAddinManagedll, and dynamically loads the user’s test dll within the file to achieve rapid loading and testing. - Through this method, multiple programs can be attached to Revit and tested.
Issue
- I have a test file called
RevitTest. My main working files areA,A.UI,A.API… If I load a method from A into the test file and test it by attaching the Add-in, an issue arises where A cannot update its dependencies correctly after being updated, requiring a restart to complete the test. The figure below shows that multiple dlls are dynamically loaded during multiple tests. This is the situation after my correction. Before modification,XGZ_Toolcould only rely on the earliest version, which is where the problem lies.

Assembly.Load()
Before understanding the specific solution, let’s understand Assembly.Load(). Through this function, we can dynamically load the required dll, which is the key function of the add-in. Load has three functions:
- The
Load()function requires passing in the strong name of the dll, similar toSystem.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. LoadFrom()will load based on the file path. If a file with the same name is encountered, it will abandon loading and continue to use the old version. Seeing the two figures below, the dependentXGZ_Toolversion numbers are consistent, but the latest version number is1.0.0.84.


LoadFile()will load based on the file path, but does not consider conditions like duplicate names, loading directly. However, it cannot load its dependencies; the dependencies need to be loaded gradually. This is the reason for my problem. Because the Add-In only loads the test file, dependencies are only introduced via the missing item mechanism during the first call. For all subsequent dependency additions, the program will first check the Runtime for a version with the same name. Since my version number has always been 1.0.0.0, the program assumes no changes and no need to load a new file with the same name, resulting in my updatedXGZ_Toolnot being updated when running.

Solution
Based on the above analysis, there are two solutions:
- Modify the version number of the program file to an auto-incrementing version. This way, calling the
LoadFile()function will automatically add the dependent version ofRevitTest.
1 | <PropertyGroup> |
- Since the mechanism of RevitAddin was mentioned earlier, if used by a company team, you can create your own Add-in based on the principles above, allowing for more flexible usage.
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.





