Red warning triangle + IMAP sync failure (InvalidCastException)

Hi,

I’m experiencing an issue with eM Client where a red warning triangle appears next to my accounts (Gmail and Outlook), and synchronization via IMAP seems to fail frequently.

  • This started happening after one of the latest app updates. I am currently running the latest version: 10.4.4867 (a1d5549) on Windows 11 (25H2 OS Build 26200.8037).
  • The issue occurs with both my Gmail and Outlook accounts.
  • I have already used the database repair function.
  • This is not isolated to my setup — a relative of mine using eM Client on a different PC is experiencing the same issue.

The problem happens consistently during normal sync. I checked the logs and found the following exception:


11:24:24 [email protected] [IMAP] System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.Int64'.

at MailClient.Protocols.Common.ItemSynchronizeContext`2.StoreItems[TUid,TVid](SynchronizationType synchronizationType, IEnumerable`1 newItems, Dictionary`2 uniqueIdToVersionId, Dictionary`2 uniqueIdToOid)

at MailClient.Protocols.Common.MailItemSynchronizeContext.StoreItems[TUid,TVid](SynchronizationType synchronizationType, IEnumerable`1 newItems, Dictionary`2 uniqueIdToVersionId, Dictionary`2 uniqueIdToOid)

at MailClient.Protocols.Common.ItemSynchronizeContext`2.<>c__DisplayClass23_0`3.<Synchronize>g__FlushItems|1(Int32 threshold)

at MailClient.Protocols.Common.ItemSynchronizeContext`2.Synchronize[T,TUid,TVid](SynchronizationType synchronizationType, IEnumerable`1 items, Func`2 getUniqueId, Func`2 getVersionId, Func`3 hasChanged, Func`2 isDeleted, Func`2 convertItems, Action`2 updateItem)

at MailClient.Protocols.Imap.SyncOperations.BaseSyncOperation.WriteSyncItemsToDb(CancellationToken& cancellationToken)

at MailClient.Protocols.Imap.SyncOperations.BaseSyncOperation.ProcessFetchNotifications(CancellationToken& cancellationToken, Boolean fromInterruption)

at MailClient.Protocols.Imap.SyncOperations.BaseSyncOperation.ProcessPriorityUpdatesAsync(CancellationToken& cancellationToken)

at MailClient.Protocols.Imap.SyncOperations.BaseSyncOperation.<>c__DisplayClass80_0.<<FetchRawMessagesAsync>g__FetchRawMessagesSlowAsync|0>d.MoveNext()

--- End of stack trace from previous location ---

at MailClient.Protocols.Imap.SyncOperations.BaseSyncOperation.FetchNewMessagesAsync(SequenceSet uidSet, UInt32 messageCountEstimate, Boolean narrowed, Boolean chunk, Boolean allowLegacyHybridMode, Boolean allowHybridRawSearch, CancellationToken cancellationToken)

at MailClient.Protocols.Imap.SyncOperations.NormalSyncOperation.FillHoles(CancellationToken cancellationToken)

at MailClient.Protocols.Imap.SyncOperations.NormalSyncOperation.SynchronizeFolder(Dictionary`2 infoOldFlags, UInt32 serverMessageCount, UInt32 newMessagesTotal, UInt32 uidNext, CancellationToken cancellationToken)

at MailClient.Protocols.Imap.SyncOperations.NormalSyncOperation.ExecuteInternalAsync(CancellationToken cancellationToken)

at MailClient.Protocols.Imap.SyncOperations.BaseSyncOperation.ExecuteAsync(CancellationToken cancellationToken)

at MailClient.Protocols.Imap.ImapMailSynchronizer.SynchronizeMessagesAsync(IItemSynchronizeContext`1 synchronizeContext, Folder folder, Boolean fast, CancellationToken cancellationToken)

at MailClient.Protocols.Imap.ImapMailSynchronizer.SynchronizeMessagesAsync(IItemSynchronizeContext`1 synchronizeContext, Folder folder, Boolean fast, CancellationToken cancellationToken)

at MailClient.Protocols.Imap.ImapMailSynchronizer.Synchronize(IItemSynchronizeContext`1 synchronizeContext, Folder folder, CancellationToken cancellationToken)

at MailClient.Protocols.Common.ItemSynchronizer`2.<>c__DisplayClass37_2.<EnqueueSynchronize>b__6(WorkerStatus status, CancellationToken ct)

at MailClient.Protocols.Imap.ImapActionCommand.<>c__DisplayClass11_0.<.ctor>b__0(WorkerStatus ws, CancellationToken ct)

at MailClient.Protocols.Imap.ImapActionCommand.ExecuteInternalSync(WorkerStatus status)

at MailClient.Protocols.Imap.ImapActionCommand.Execute(WorkerStatus status)

at MailClient.Commands.Command.Process(WorkerStatus status)

--- End of stack trace from previous location ---

at MailClient.Protocols.Imap.ImapAccount.SynchronizeIntAsync(Boolean forced)

at MailClient.Protocols.Common.SynchronizableMailAccount.<>c__DisplayClass22_0.<<SynchronizeAsync>b__0>d.MoveNext()

IMAP_SERVER_TYPE = Gmail

RunInPlace = False

GUIStatus_Exception_Reported = True



Hi, this is unfortunately a major server‑side issue, but our developers have been preparing a workaround on our end. It hasn’t been officially released yet, but I’ll DM you an internal build if you’d like to install it. We’ll appreciate any feedback.

Hi Kim, thank you for the quick response and for providing a workaround — I really appreciate it.

I’d be happy to test the internal build and provide feedback.

Before proceeding, I have a couple of questions:

  • Can I install this build as an update over my current version, or does it require a clean install?
  • If a clean install is required, will I need to fully re-sync my accounts?

I’m asking because one of my accounts is around 250GB, so a full re-sync would take several days.

Also, do you have an estimated timeline for when this fix might be officially released?

Thanks again for your help!

It’s worth making a backup first in case you’d like to smoothly downgrade to your currently installed version later, but otherwise it’s as simple as installing it over your current installations.

We don’t have an estimate just yet, but the testing is underway.

Hi Kim, I’m facing exactly the same issue as described in this thread and I also would be interested to test the beta version, so is there any possibility to get my hands on it?

Hi Kim, I’m experiencing the same issue. Since updating to the latest version, my emails are no longer being updated. Synchronization is running continuously. Like Herhey, I’m using Windows 11, version 25 H2.
Please let me know immediately if and how this bug can be fixed.

This update has been working flawlessly so far. Will I receive future updates once they’re officially released, or does this build have a separate update path?

Yes, you will receive updates!