diff --git a/src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj b/src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj
index 3f8f859c4f45d..ef2dd3aa7ed4a 100644
--- a/src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj
+++ b/src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj
@@ -4,8 +4,8 @@
$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);netcoreapp3.1-windows;netcoreapp3.1;netstandard2.0-windows;netstandard2.0
true
- false
- 0
+ true
+ 1
true
true
true
diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs
index 72d92119acd79..3bcc0e8e6e298 100644
--- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs
+++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs
@@ -38,7 +38,6 @@ public class MemoryCache : ObjectCache, IEnumerable, IDisposable
private readonly bool _configLess;
private bool _useMemoryCacheManager = true;
private EventHandler _onAppDomainUnload;
- private UnhandledExceptionEventHandler _onUnhandledException;
#if NET5_0_OR_GREATER
[UnsupportedOSPlatformGuard("browser")]
private static bool _countersSupported => !OperatingSystem.IsBrowser();
@@ -221,9 +220,6 @@ private void InitDisposableMembers(NameValueCollection config)
EventHandler onAppDomainUnload = new EventHandler(OnAppDomainUnload);
appDomain.DomainUnload += onAppDomainUnload;
_onAppDomainUnload = onAppDomainUnload;
- UnhandledExceptionEventHandler onUnhandledException = new UnhandledExceptionEventHandler(OnUnhandledException);
- appDomain.UnhandledException += onUnhandledException;
- _onUnhandledException = onUnhandledException;
dispose = false;
}
finally
@@ -240,16 +236,6 @@ private void OnAppDomainUnload(object unusedObject, EventArgs unusedEventArgs)
Dispose();
}
- private void OnUnhandledException(object sender, UnhandledExceptionEventArgs eventArgs)
- {
- // if the CLR is terminating, dispose the cache.
- // This will dispose the perf counters
- if (eventArgs.IsTerminating)
- {
- Dispose();
- }
- }
-
private void ValidatePolicy(CacheItemPolicy policy)
{
if (policy.AbsoluteExpiration != ObjectCache.InfiniteAbsoluteExpiration
@@ -507,10 +493,6 @@ private void DisposeSafeCritical()
{
appDomain.DomainUnload -= _onAppDomainUnload;
}
- if (_onUnhandledException != null)
- {
- appDomain.UnhandledException -= _onUnhandledException;
- }
}
private object GetInternal(string key, string regionName)