Skip to content

Conversation

@benglin
Copy link
Contributor

@benglin benglin commented Oct 27, 2025

Purpose

🐛 Bug Fix: Resolves an Assembly.LoadFrom exception when loading DynamoInstallDetective.dll in DynamoRevit scenarios.

Problem: When DynamoUnits attempts to dynamically load DynamoInstallDetective.dll to discover ASC (Autodesk Single Sign-On Client) unit schema paths, it fails in DynamoRevit with the error:

Could not load file or assembly 'DynamoInstallDetective, Version=4.0.0.2941, Culture=neutral, PublicKeyToken=null'.
Assembly with same name is already loaded

Root Cause: DynamoRevit loads DynamoInstallDetective.dll at startup, but DynamoUnits was attempting to load it again using Assembly.LoadFrom(). When .NET detects an assembly with the same name already loaded but with a different version or location, it throws an exception.

Solution: Check if DynamoInstallDetective is already loaded in the current AppDomain before attempting to load it. This allows the code to:

  • ✅ Use the already-loaded assembly in DynamoRevit scenarios
  • ✅ Load from disk in standalone DynamoSandbox scenarios
  • ✅ Gracefully handle both deployment contexts

Declarations

Check these if you believe they are true

Release Notes

Fixed assembly loading exception in DynamoRevit when DynamoUnits attempts to discover ASC unit schema paths. The fix checks if DynamoInstallDetective.dll is already loaded in the AppDomain before attempting to load it, preventing version conflicts between host applications and the DynamoUnits library.

Screenshots

✅ DynamoSandbox - Working

DynamoSandbox successfully loads DynamoInstallDetective.dll from disk and discovers ASC unit schemas

asc-dynamo-sandbox

✅ DynamoRevit - Working

DynamoRevit successfully uses the already-loaded DynamoInstallDetective assembly without conflicts

asc-dynamo-revit

Testing

  • ✅ Verified in standalone DynamoSandbox.exe
  • ✅ Verified in Dynamo for Revit Preview Release
  • ✅ Confirmed no exceptions thrown in either scenario
  • ✅ ASC unit schema discovery works correctly in both contexts

Reviewers

(FILL ME IN) Reviewer 1

Note to Reviewers: This is a defensive fix that improves robustness when DynamoUnits is used in different host application contexts. The change is backward compatible and doesn't affect the public API.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@benglin benglin added this to the 4.0 milestone Oct 27, 2025
Copilot AI review requested due to automatic review settings October 27, 2025 04:34
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-9747

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an assembly loading exception in DynamoRevit by checking if DynamoInstallDetective.dll is already loaded before attempting to load it. The issue occurred because DynamoRevit loads this assembly at startup, but DynamoUnits was attempting to load it again, causing version/location conflicts.

  • Checks AppDomain for already-loaded DynamoInstallDetective assembly before loading
  • Falls back to Assembly.LoadFrom() only when assembly is not already loaded
  • Maintains backward compatibility with standalone DynamoSandbox scenarios

@QilongTang
Copy link
Contributor

Restarted PR check at https://master-5.jenkins.autodesk.com/job/Dynamo/job/DynamoSelfServe/job/pullRequestValidation/18727/

@QilongTang
Copy link
Contributor

Restarted PR check at https://master-5.jenkins.autodesk.com/job/Dynamo/job/DynamoSelfServe/job/pullRequestValidation/18727/

Given this passed, merging

@QilongTang QilongTang merged commit 501b338 into master Oct 27, 2025
26 of 28 checks passed
@QilongTang QilongTang deleted the DYN-9747 branch October 27, 2025 20:03
github-actions bot pushed a commit that referenced this pull request Oct 27, 2025
@github-actions
Copy link

Successfully created backport PR for RC4.0.0_master:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants