© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Search
Star
Feedback
Setup for Free
C
C#
•
4y ago
nicke
AssemblyLoadContext not unloading if system.runtime.caching MemoryCache used inside ALC.
Our use cases allows third parties to create plugins
, so we do not have full control of how they are implemented
.
When using AppDomains in
.net framework MemoryCache was disposed internally by the MemoryCache implementation when AppDomain unloaded see
:
https://github.com/microsoft/referencesource/blob/dae14279dd0672adead5de00ac8f117dcf74c184/System.Runtime.Caching/System/Caching/MemoryCache.cs#L185
Problem is the unload event is not implemented in
.NET 6 for AppDomains
.
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/AppDomain.cs#L67
Is there any other way than fixing the plugin code to listen for AssemblyLoadContext
.Unloading event and Dispose of the MemoryCache
?
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Similar Threads
Forcefully unloading AssemblyLoadContext
C
C# / help
2y ago
❔ MemoryCache
C
C# / help
3y ago
Debugger preventing AssemblyLoadContext unload
C
C# / help
2w ago
AssemblyLoadContext LoadfromAssemblyPath vs LoadFromNativeImagePath
C
C# / help
2y ago