Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Apr 11, 2019 8:52 pm

I've setup an API service to receive a document request, copy it to an input stream, then LoadFromStream to a Spire.Doc Document. When submitting multiple requests at the same time (ie. 5 word document requests); i receive an error: Collection was modified; enumeration operation may not execute. How can I make this thread safe? In the forum, there were two other posts from 2014/2015, but not a clear solution.

httpRequest.Files[0].InputStream.CopyTo(ms);
Document document = new Document();
document.LoadFromStream(ms, FileFormat.Auto); <--- Error occurs here when two documents process at the same time.


I have tried the decorator [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single)], but that didn't seem to solve the issue.

tholland
 
Posts: 22
Joined: Fri Dec 01, 2017 6:38 pm

Fri Apr 12, 2019 8:57 am

Hello,

Thanks for your inquiry.
After an initial test with our latest Spire.Doc Pack(hot fix) Version:7.4.6, I didn't reproduce your issue. To help us do a better investigation, please share us with your runnable application as well as the details of your testing steps. You could send them to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc

cron