[Cherry-pick] DYN-9747: Fix ASC schema detection in Dynamo Revit #16653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #16651 to
RC4.0.0_masterPurpose
🐛 Bug Fix: Resolves an
Assembly.LoadFromexception when loadingDynamoInstallDetective.dllin DynamoRevit scenarios.Problem: When DynamoUnits attempts to dynamically load
DynamoInstallDetective.dllto discover ASC (Autodesk Single Sign-On Client) unit schema paths, it fails in DynamoRevit with the error:Root Cause: DynamoRevit loads
DynamoInstallDetective.dllat startup, but DynamoUnits was attempting to load it again usingAssembly.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
DynamoInstallDetectiveis already loaded in the current AppDomain before attempting to load it. This allows the code to: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.dllis 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
✅ DynamoRevit - Working
DynamoRevit successfully uses the already-loaded DynamoInstallDetective assembly without conflicts
Testing
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