When listing the mail messages, the Version 23.06 is crashing with the following Callstack:
[SynchronizationLockException: Object synchronization method was called from an unsynchronized block of code.]
at #=zYVUw7jwkj9CmUX7a$BGiyW0QxLDN.#=zIWX$z1w=()
at #=zYVUw7jwkj9CmUX7a$BGiyW0QxLDN.Dispose()
at Aspose.Email.Clients.EmailClient.Dispose(Boolean disposing)
at Aspose.Email.Clients.EmailClient.Dispose()
at Aspose.Email.Clients.Imap.ImapClient.Dispose()
at App.IMAPMailClient.ListMessages(IMAPConnectParam connectParam, String strFolder)
Sample code:
using(ImapClient client = Connect(connectParam))
{
if(!client.ExistFolder(strFolder)) throw new ArgumentOutOfRangeException(strFolder);
client.SelectFolder(strFolder);
ImapMessageInfoCollection imapMessageInfos = client.ListMessages();
return imapMessageInfos.Select(info => new IMAPListMessageResult { Subject = info.Subject, MessageId = info.MessageId }).ToArray();
}
Hi @patrick.weibel
Thanks for your question.
Are you using multithreading in your application? Could you please provide the complete code (Connect method) to understand how the ImapClient is created?
Hi @alexander.pavlov
We do no multithreading in our application. It is used in an asp.net webforms application with .net framework 4.8.1.
Here the connect Method:
private ImapClient Connect(IMAPConnectParam param)
{
ImapClient client = new ImapClient(param.Server, param.Username, param.Password);
if(param.ServerPort.HasValue) client.Port = param.ServerPort.Value;
if(param.UseSSL)
{
client.SecurityOptions = SecurityOptions.SSLAuto;
}
if(param.UseProxy)
{
if(!param.UseSSL) client.SecurityOptions = SecurityOptions.Auto;
string proxyAddress = param.ProxyServer; // proxy address
SocksProxy proxy = new SocksProxy(proxyAddress, param.ProxyServerPort, SocksVersion.SocksV5);
client.Proxy = proxy;
}
return client;
}
Best regards
Patrick
Hi @patrick.weibel
We can not to reproduce your issue yet. Please try to use the latest version of the API and give your feedback.
Hi @alexander.pavlov
I just found out, that we run the code with several threads. Does it mean, that this code is not thread safe?
Best regards
Patrick
Hi @patrick.weibel
We cannot determine the thread safety of the code by its parts, but the type of error indicates this problem. If you could provide the complete code (maybe a small console application?) that reproduces the error, we can understand the issue.