Skip to content

Commit 3e316d4

Browse files
committed
fix: improve dependency resolution for .NET Core assemblies
Enhanced the _get_reference_file function to handle scenarios where .NET Core loads framework assemblies from the shared runtime. Added logic to check for already loaded assemblies and return their locations, preventing potential loading conflicts.
1 parent eb047a5 commit 3e316d4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pyrevitlib/pyrevit/runtime/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ def _get_framework_sdk_module(fw_module):
180180

181181
def _get_reference_file(ref_name):
182182
mlogger.debug('Searching for dependency: %s', ref_name)
183+
# On netcore the host often loads framework assemblies from the shared runtime
184+
# (e.g. System.Collections.Immutable 8.x). A newer copy in bin/ may be 9.x;
185+
# Assembly.LoadFrom that path then fails while the same name is already loaded.
186+
if NETCORE:
187+
loaded_asm = assmutils.find_loaded_asm(ref_name)
188+
if loaded_asm:
189+
mlogger.debug('Using host-loaded dependency: %s @ %s', ref_name,
190+
loaded_asm[0].Location)
191+
return loaded_asm[0].Location
192+
183193
# First try to find the dll in the project folder
184194
addin_file = framework.get_dll_file(ref_name)
185195
if addin_file:

0 commit comments

Comments
 (0)