This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
Store Activity wrapped into ObjectHandle in Logical CallContext #20963
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.
This change addresses issue when an application has Activity stored in the logical call context and makes a call to another AppDomain that do not have DiagnosticSource.dll loaded.
In this case, an application may crash failing to find DiagnosticSource.dll. This issue potentially affects Azure CloudService users on NET .45 that use some features (role environments change events) of WindowsAzure.ServiceRuntime and ApplicationInsights
So this change stores Activity wrapped into
ObjectHandle
in the logical call context.First of all, it allows using AppDomains that do not load DiagnosticSource. It also allows to remove Serializable attribute (see below why it's a good thing) as
ObjectHandle
implementsMarshalByRefObject
.Supporting [Serializable] Activity across AppDomains creates several issues:
So, this change does not allow different AppDomains reuse Activity.
This is also important to allow wrapping Activity into
ObjectHandle
: Activity does not inherit fromMarshalByRefObject
and could not be used remotely by reference anyway.Changing Activity to inherit from the
MarshalByRefObject
creates some complications and does not bring any value (see p3 above).Activity was never released as stable and chances that someone already uses it in cross AppDomain calls on .NET 4.5 are inconceivable.
These changes were tested manually on .NET 4.5. Automation is in progress in partner team infrastructure (ApplicationInsights).
@vancem @SergeyKanzhelev @stephentoub please review
Fixes #21027