You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you execute Newtonsoft.Json.JsonConvert.Serialize() on a custom object defined in an assembly in a collectible AssemblyLoadContext, the AssemblyLoadContext can no longer be unloaded.
It obviously happens because of using a number of different caches like ConvertUtils.CastConverters with strong references and without any possibility to remove them (but reflection which seems like a bad workaround).
The text was updated successfully, but these errors were encountered:
It's not because of the Json.NET caches - they can be unloaded if Json.NET is itself loaded into the AssemblyLoadContext (their statics live in the load context).
The inability to unload is apparently due to the usage of the System.ComponentModel wrappers - that assembly is loaded into the default context and also caches quite a lot of things (and these caches living in the default context are causing the problem). You can apparently forcefully load it into your own AssemblyLoadContext though, but the AssemblyDependencyResolver won't help you with this.
If you execute Newtonsoft.Json.JsonConvert.Serialize() on a custom object defined in an assembly in a collectible AssemblyLoadContext, the AssemblyLoadContext can no longer be unloaded.
It obviously happens because of using a number of different caches like ConvertUtils.CastConverters with strong references and without any possibility to remove them (but reflection which seems like a bad workaround).
The text was updated successfully, but these errors were encountered: