Include full requesting assembly chain in assembly load failure exceptions#125795
Draft
Include full requesting assembly chain in assembly load failure exceptions#125795
Conversation
When an assembly fails to load, the FileLoadException/FileNotFoundException now includes the name of the requesting (parent) assembly in the FusionLog property. This helps diagnose dependency chain issues by showing which assembly triggered the failed load. The information flows from the native AssemblySpec::GetParentAssembly() through EEFileLoadException::CreateThrowable() to the managed exception's FusionLog property, which is displayed in ToString() output. Fixes #9185 Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
BadImageFormatException is also created by EEFileLoadException::CreateThrowable() when the HRESULT maps to kBadImageFormatException. Without the 3-arg constructor, the requesting assembly info would be silently dropped for bad image format errors. Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
elinor-fung
March 19, 2026 19:12
View session
Member
|
@copilot we should include the full requesting assembly chain instead of just the parent. |
Walk the inner exception chain to build the full dependency path. When A→B→C→D and D fails, D's FusionLog now shows: Requesting assembly: 'C' Requesting assembly: 'B' Requesting assembly: 'A' At each Throw(AssemblySpec*) level, the current parent assembly name is appended to every inner EEFileLoadException's chain. The managed FormatRequestingAssemblyChain helper formats each newline-separated name with the "Requesting assembly:" resource string. Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Contributor
Author
Updated in 228155e. Now at each The managed |
Copilot
AI
changed the title
Include requesting assembly in assembly load failure exceptions
Include full requesting assembly chain in assembly load failure exceptions
Mar 19, 2026
…dd tests The requesting assembly chain is now appended to the exception's Message property instead of FusionLog. This means users see the chain directly in the exception message when it is thrown, without needing to inspect FusionLog separately. Added tests for all three exception types (FileLoadException, FileNotFoundException, BadImageFormatException) that verify: - Single requesting assembly appears in Message - Multiple requesting assemblies (chain) appear in Message - FusionLog remains null Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
…missing transitive dependency Remove the 6 reflection-based tests that invoked private constructors via reflection from BadImageFormatExceptionTests, FileLoadExceptionTests, and FileNotFoundExceptionTests. Add an integration test in System.Runtime.Loader.Tests that creates a real dependency chain (Root -> Mid -> Leaf) where the transitive dependency (Leaf) is missing at runtime. The test verifies that a FileNotFoundException is thrown with the correct missing assembly name when the chain is exercised. Three helper assembly projects are added: - MissingDependency.Leaf (not deployed via PrivateAssets=all) - MissingDependency.Mid (depends on Leaf) - MissingDependency.Root (depends on Mid) Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
The test now asserts that the FileNotFoundException message contains "MissingDependency.Mid" (the requesting assembly), verifying that the entire dependency chain is reported in the exception message, not just the missing assembly file name. Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.