Skip to content

Implemented assembly redirect for non-default AppDomain#4728

Draft
iskiselev wants to merge 4 commits intoopen-telemetry:mainfrom
iskiselev:redirect
Draft

Implemented assembly redirect for non-default AppDomain#4728
iskiselev wants to merge 4 commits intoopen-telemetry:mainfrom
iskiselev:redirect

Conversation

@iskiselev
Copy link
Contributor

@iskiselev iskiselev commented Dec 24, 2025

Why

Exisitng solution #4187 force LoaderOptimization.SingleDomain for every additional app domains. It is not standard behaviour and may result in increased memory consumption and slower warm-up for process hosting multiple web-applications - and other processes that use additional AppDomains.

Implement second stage of fix for #4186.

What

Added environment variable OTEL_APP_DOMAIN_STRATEGY that controls strategy of fixing assembly conflicts in non-default app domains.
Possible values:

  • None - do not apply anything. Works with test app and OTEL 1.14, crash with Loading this assembly would produce a different grant set from other instances #4186 on OTEL 1.13. May be useful for custom host that creates AppDomains.
  • LoaderOptimizationSingleDomain - exisiting solution implemented in Automatic LoaderOptimization.SingleDomain #4187 - all additional AppDomains use LoaderOptimization.SingleDomain - used by default
  • AssemblyRedirect - new stategy - patch assemblyBindings/dependentAssembly/bindingRedirect in memory-loaded app.config. On test app docker requires app pool to loading user profile if assemblies loaded from folder (and has no issues when assemblies are registered in GAC). On my local computer works even without loading user profile for app pool.

Tests

AspNetTests.SubmitsTraces now test additional modes.

Checklist

  • CHANGELOG.md is updated.
  • Documentation is updated.
  • New features are covered by tests. - AspNetTests.SubmitsTraces use for e2e validation, but config modification better to cover with unit test.
  • How new setting should be integrated with file-based config?

Introduce OTEL_APP_DOMAIN_STRATEGY to control AppDomain config update strategies for .NET Framework, supporting LoaderOptimization, assembly redirects, or no action. Add dynamic app.config modification for assembly binding redirects via AppConfigUpdater and new AssemblyCatalog. Expand IIS tests to cover all strategies.
@iskiselev
Copy link
Contributor Author

iskiselev commented Dec 24, 2025

Some special processing required for MongoDB - should be validated. Probably we should not include MongoDB dll in our distro at all, if we are not loading it?

SOLVED: We do not use any special processing for MongoDB anymore and do not include it in distro

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we try to parse app.config when we check it? Which app.config should be used - creator domain or target domain?
How should be file-based config be integrated here?
For now, I plan to add it to the list of settings supported only by environment variables.

…AIN_STRATEGY`

Added documentation and changlog information.
Handled creation of config when not provided by AppDomain
existingNewVersion = new Version(0, 0);
}

if (existingNewVersion >= assemblyInfo.Version)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be bad if app uses newer version of the same assembly that we need, but does not have binding redirect.
To solve it better, we may need implement scan of assembly folders and GAC to check if newer version exisists. I do not plan to do it in that PR, but can be done later if any requests will come.

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.

1 participant

Comments