BusinessRuleAsync intermittently loses underlying ApplicationDbContext #3490
Replies: 2 comments 14 replies
-
I do notice some System.ObjectDisposedExceptions in the Output window when debugging in one of the BusinessRuleAsync rules which was If I switch on the debugger to break on these types of exceptions, I see things like;
or at other times
I think my real question is this. How do I setup an asp net core app to have scoped dbcontext and scoped repository services, but have the async business rules use their own independent dbcontext thus avoiding disposed object or “this dbcontext cannot share - is not thread safe”. |
Beta Was this translation helpful? Give feedback.
-
Is this with a local or remote data portal? |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Have a complex BusinessEditBase model with a list of child objects. Both have a few async business rules that do database lookups (EF Core). This is a Net6 Web API.
Now and again (yes its annoying - it's intermittent), a BusinessRuleAsync rule will fail to run with Object Disposed error on lines like this;
Drilling into the error in the CheckLinesInRangeList object, seems the underlying ApplicationDbContext has been disposed.
Now I appreciate this may be a more general DotNet Core issue rather than Csla, but would any type of using block cause the issue? I'm DI'ing the context in, and do not dispose of it manually anywhere.
One rule is using a ReadOnlyListBase and has a
using (LoadListMode)
wrapped around the database call - surely that would not cause the ApplicationDbContext to dispose? When they say a using block they of course mean using (ctx = ApplicatioDbContext) sort of thing.Version and Platform
CSLA version: 7.0.0
OS: Windows, Linux, iOS, Android, etc.
Platform: ASP.NET Core
Additional context
Running on IIS
Beta Was this translation helpful? Give feedback.
All reactions