-
or in any other scenarios where multiple scopes are involved... Why? If I am right, because all CSLA objects now contain a scoped ApplicationContext reference which contains an IServiceProvider. This IServiceProvider belongs to the scope that fetched the object and that gets disposed when that user logs off. Background: I'm happily converting piece by piece of our legacy WebForms app (CSLA 5.2) to our shiny new Blazor Server Side app using CSLA 6 :-) Today I migrated over the ApplicationCache mechanism. It used to be a static class living in Application scope on web server. Now it is an injected singleton service in Blazor. It simply stores various readonly lists of objects fetched frequently for lookups and tracks when it should be fetched fresh. Trouble is, the first user to fetch a list populating the cache used their ApplicationContext for the Fetch. Now that user logs off. [2022-09-15T00:05:34.811Z] Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'IServiceProvider'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Csla.Core.ApplicationContextAccessor.GetContextManager()
at Csla.ReadOnlyBase`1.VerifyAuthorizationCache()
at Csla.ReadOnlyBase`1.CanReadProperty(IPropertyInfo property)
at Csla.ReadOnlyBase`1.CanReadProperty(IPropertyInfo property, Boolean throwOnFalse)
at Csla.ReadOnlyBase`1.GetProperty[P](PropertyInfo`1 propertyInfo, NoAccessBehavior noAccess)
at BL.Agency.AgencyInfo.get_AgcStatus() in C:\Repos\LIMS-plus\BL\Agency\AgencyInfo.cs The After pacing around my house for several hours, I'm wondering if I am correctly realizing that CSLA objects (because of the nice happy new dependency injection underpinings) must now absolutely always:
@rockfordlhotka Please advise - and prepare for me to go find the nearest tall bridge (luckily I live in a desert with no bridges nearby so I will likely die of thirst first walking to find one). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
FYI - just for giggles I went into one of the ReadOnly classes and changed all the GetProperty statements to ReadProperty. Then I repeated the login/fetchcache/logoff/login/fetchcache action and the error is gone because the underlying framework code to check permissions isn't being triggered now in the objects that were fetched by the initial scope. Worth mentioning that none of the ReadOnly objects that go in the Singleton cache have any security to them.... they are just lookup objects / lists that anyone can fetch. So technically I could make all the gets reads, but this feels like a deeper problem that I will bump into elsewhere. Brainstorming for possible solutions:
|
Beta Was this translation helpful? Give feedback.
-
@rockfordlhotka answered above :-) |
Beta Was this translation helpful? Give feedback.
@rockfordlhotka answered above :-)