Document Service Fabric interception, scoping, and package versioning - #188
Merged
Conversation
Several long-standing issues on the Autofac.ServiceFabric repo were documentation gaps rather than code defects. Cover them here: - Registration requirements for the dynamic proxy, including which form of InternalsVisibleTo an internal service type needs. The keyed Castle constant only works from a strong-named assembly, and using it from an unsigned one is the usual cause of "Access is denied". - Where the Service Fabric context objects are registered, and why a component depending on ServiceContext cannot be SingleInstance. - The configurationAction hook, which is the only place a component that needs ServiceContext at construction can be registered. - That the Microsoft.ServiceFabric.* packages pin each other exactly, so consumers need to align their SF package versions. Also drops the Example section. It linked to a sample that no longer exists in the Examples repository, on a branch that has been renamed. Fixes #187.
This was referenced Aug 14, 2026
Closed
This was referenced Aug 14, 2026
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.
Fixes #187.
Three long-standing issues on the Autofac.ServiceFabric repo turned out to be documentation gaps rather than code defects. They're being closed in favor of #187, and this covers them.
What's added
Registration Requirements — the page never mentioned that every registered service and actor type is wrapped in a dynamic proxy, or what that requires (class, not
sealed/abstract, onlyvirtualmembers intercepted). Those constraints only existed in API XML docs.Internal Service Types — resolves Autofac.ServiceFabric#49. An internal service type needs
InternalsVisibleToforDynamicProxyGenAssembly2, and which form depends on whether the consumer's own assembly is strong named, because Castle only signs its generated assembly when the assembly holding the proxied type is signed. Using the keyedCastle.Core.Internalconstant from an unsigned assembly is what producesAccess is denied— a genuinely misleading error for the actual cause. Added a note saying so explicitly, since people reasonably assume it's about whetherAutofac.ServiceFabricis signed.Service and Actor Lifetime Scopes — resolves Autofac.ServiceFabric#51. Documents that the SF context objects are registered into the per-replica child scope, not the root container, and therefore that a component depending on
ServiceContextcan't beSingleInstance(). Shows the failing registration next to theInstancePerMatchingLifetimeScope("ServiceFabric")fix. Also notes thatLazy<T>/Func<T>don't help, since that's what the reporter tried first.Adding Registrations to the Service Scope — documents the
configurationActionparameter ofRegisterServiceFabricSupport, which shipped in v4.0.0 and was never documented. Uses the Application InsightsFabricTelemetryInitializerexample from Autofac.ServiceFabric#57, which is the scenario it was built for.Service Fabric Package Versions — resolves Autofac.ServiceFabric#18, open since 2017. The
Microsoft.ServiceFabric.*packages pin each other to exact versions, so the versionAutofac.ServiceFabricdepends on effectively sets the SF package version for the whole consuming project. Mixing versions yieldsNU1608. Documented as guidance because it's inherent to Microsoft's versioning and the integration can't work around it.What's removed
The Example section. It linked to
autofac/Examples/tree/master/src/ServiceFabricDemo, and that directory was deleted from the Examples repo — on a branch that has since been renamed frommastertomain, so the link was dead twice over. Rather than leave a broken link or replace it with meta-commentary about missing content, the section is gone; it should be restored when a current sample lands (tracked separately in the Examples repo).Deliberately not included
The
constructorExceptionCallbacksignature change from Autofac.ServiceFabric#47 is unreleased, so documenting it now would describe API that isn't on NuGet yet. That belongs with the next release.Verification
doc8clean, and a fullsphinx -b htmlbuild succeeds with every new section rendering correctly. The only build warnings are two pre-existingunknown document: '../troubleshooting/diagnostics'references infaq/container-analysis.rstandlifetime/disposal.rst, unrelated to this change.