Skip to content

Document binding redirect generation for unit test projects (DLL targets)#51969

Merged
BillWagner merged 3 commits into
mainfrom
copilot/improve-assembly-binding-docs
Mar 2, 2026
Merged

Document binding redirect generation for unit test projects (DLL targets)#51969
BillWagner merged 3 commits into
mainfrom
copilot/improve-assembly-binding-docs

Conversation

Copilot AI commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Unit test projects compile to DLLs and are silently excluded from automatic binding redirect generation, causing runtime FileLoadException when assembly version conflicts exist—with no documentation explaining why or how to fix it.

Changes

  • redirect-assembly-versions.md: Added a new subsection under "Redirect versions for tests, plugins, or libraries used by another component" explaining:
    • Why DLL output types are excluded from automatic binding redirect generation
    • How to force .dll.config generation via two MSBuild properties
    • That VSTest and most test runners automatically load the generated config file
<PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

After rebuilding, a .dll.config file appears alongside the test assembly in the output directory containing the generated binding redirects.

Original prompt

This section details on the original issue you should resolve

<issue_title>[New Topic] Improve documentation on Assembly Binding Redirection </issue_title>
<issue_description>Currently, assembly binding redirection documentation is messy and difficult to locate. This is especially true if you're not able to use automatic binding redirection, such as if you are:

  • Writing unit tests (which compile to DLLs, and don't get automatic binding redirects)
  • Writing DLLs that are consumed in dynamic languages (Powershell, Python)

Most of the documentation is spread across multiple documentation pages, and the bulk of it is not written for .NET Core. Unfortunately, it's incredibly easy to end up with binding redirect problems if you're consuming .NET Standard DLLs from a project that targets either .NET Framework or dual-targets Framework and Core.

This can be improved by:

<agent_instructions>Limit the fix to providing information necessary for unit testing scenarios.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@mairaw Thanks @SZ-MSFT for your feedback. @richlander @terrajobst who would know about this and what we want to expose in the docs? @ The existing documentation doesn't explain DLL targets do not get redirection, so they need to be handled manually - this is important if you're writing DLLs that are consumed by dynamic languages, or if you're writing unit tests.

Specifically, it would be great to see documentation on how to get unit tests working (which require special flags in the csproj to allow for redirection to work on a unit test target) - the GenerateBindingRedirectsOutputType flag:
microsoft/vstest#428 (comment)

It would also be great to see an example on how to do binding redirection in code, like in the example I linked to in the original post. If you're someone who is consuming DLLs via dynamic languages, that's the only way to ensure binding redirection works correctly.

@dotnet-bot This issue has been closed as part of the issue backlog grooming process outlined in #22351.

That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the @dotnet/docs team for visibility.</comment_new>
<comment_new>@BillWagner
reopening per comment.</comment_new>


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.


Internal previews

📄 File 🔗 Preview link
docs/framework/configure-apps/redirect-assembly-versions.md Redirect assembly versions

…utputType

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve documentation on assembly binding redirection Document binding redirect generation for unit test projects (DLL targets) Mar 2, 2026

@BillWagner BillWagner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is ready for final review.

@BillWagner BillWagner marked this pull request as ready for review March 2, 2026 19:34
@BillWagner BillWagner requested a review from a team as a code owner March 2, 2026 19:34
Copilot AI review requested due to automatic review settings March 2, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the .NET Framework assembly binding redirect documentation to explain why unit test projects (DLL outputs) don’t get automatic binding redirect generation and how to enable .dll.config generation via MSBuild properties.

Changes:

  • Expanded article metadata to reflect added unit test guidance.
  • Added a new subsection describing how to generate binding redirects for unit test projects by setting AutoGenerateBindingRedirects and GenerateBindingRedirectsOutputType.

Comment thread docs/framework/configure-apps/redirect-assembly-versions.md
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BillWagner BillWagner enabled auto-merge (squash) March 2, 2026 22:13
@BillWagner BillWagner merged commit 8929b6b into main Mar 2, 2026
11 checks passed
@BillWagner BillWagner deleted the copilot/improve-assembly-binding-docs branch March 2, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[New Topic] Improve documentation on Assembly Binding Redirection

5 participants