Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.ObjectDisposedException when using IMAP #1126

Closed
Sajito opened this issue Jul 7, 2022 · 1 comment
Closed

System.ObjectDisposedException when using IMAP #1126

Sajito opened this issue Jul 7, 2022 · 1 comment

Comments

@Sajito
Copy link

Sajito commented Jul 7, 2022

When accessing the messages through IMAP, the actions won't be saved. Instead the log fills with errors about already disposed context.

Error trying to mark as read:

System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'Smtp4devDbContext'.
   at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed()
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Internal.IDbContextDependencies.get_EntityFinderFactory()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_Finder()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.FindAsync(Object[] keyValues)
   at Rnwood.Smtp4dev.Data.MessagesRepository.<>c__DisplayClass6_0.<MarkMessageRead>b__0() in /app/Rnwood.Smtp4dev/Data/MessagesRepository.cs:line 30
   at Rnwood.Smtp4dev.Server.TaskQueue.<>c__DisplayClass2_0.<QueueTask>b__0() in /app/Rnwood.Smtp4dev/Server/TaskQueue.cs:line 28

Error trying to delete:

System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'Smtp4devDbContext'.
   at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed()
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.get_Model()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.CheckState()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
   at Rnwood.Smtp4dev.Data.MessagesRepository.<>c__DisplayClass8_0.<DeleteMessage>b__0() in /app/Rnwood.Smtp4dev/Data/MessagesRepository.cs:line 47
   at Rnwood.Smtp4dev.Server.TaskQueue.<>c__DisplayClass2_0.<QueueTask>b__0() in /app/Rnwood.Smtp4dev/Server/TaskQueue.cs:line 28

Not sure if relevant, but I'm using Thunderbird 102 as IMAP client.

rnwood added a commit that referenced this issue Jul 12, 2022
@brad-agencyroot
Copy link

Ran into a very similar issue when attempting to add flags to messages. We ended up rolling back to version 3.1.3.2 which is working fine for our needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants