How to best handle dll conflicts with revit addins
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Over the past week I have been trying to add telemetry to an internal tool that our company is creating for revit. This is a revit plugin targeting both net 8 and net framework 48 versions of revit. I'm attempting to add telemetry I had to resolve issues with version conflicts of dlls (as I expected I would). In the past we have recommended dropping support for net framework versions of tools as the net core solution is relatively simple, however, obviously this is not possible for revit as moving to newer versions can take project teams a long time (that's if they even decide to do so).
I'm wondering if anyone has discovered the silver bullet for building addins with dependencies that may be of different versions to those used by revit and/or other plugins?
What I have tried (and what I dislike/like about each solution).
- AssemblyLoadContext - this is by far my preferred solution but not compatible with .net framework
- IL-repack #1 - basically create a thin addin that calls the core assembly which is packed using IL-repack and only externalise the necessary types. This was somewhat elegant but lost the ability to hot reload
- IL-repack #2 - create a separate project for all my dependencies that would be packed and referenced by the addin project. I found with this solution I had to be careful referencing nuget packages as I needed to match my framework version targets. OK solution as will work with all versions of revit and hot reload will work, but build steps are kind of complicated and care needs to be taken with nuget versions as transitive dependencies would ideally match. I found that if versions of framework references do not match, the build will output the version referenced by the nuget package and would be packed resulting in the type existing both in my packed dll and as part of the framework references used in the addin project.
- A combination of 1 & 2 in which 1 is used for Revit >= 2025 and 2 is used for Revit <= 2024. This solution felt ok as there wasn't a great deal of branching code for handling a direct reference to a dll and using assembly load context. Hot reload would work with Revit >= 2025 but not for the IL-repack solution.
I didn't really find the silver bullet I was looking for, and I'm tired of dealing with MSBuild. Has anyone got a better solution that I have not yet thought of?
Developer Advocacy and Support + 