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.

Fri Feb 03, 2023 2:03 pm

Application Setup
1. We are using Spire.Office v 7.12.4, .Net 6.0, and C# in Visual Studio 2022 environment
2. We are testing an Azure Service Bus with a topic and a subscription
3. C# Function App is deployed in Azure and is triggered whenever a message is published to the topic
4. Function App consumes Spire.Office library to dynamically replace place holders in a Word document with custom text and writes it to Azure File Storage as a PDF file
5. Host.json sets maxConcurrentCalls to the Function App to 16 and maxConcurrentSessions to 8
6. We have a separate Console application that fires messages to the topic, and we observe the behavior of the function by analyzing its logs

Application Behavior
1. We observed that even under a moderate load of 100 messages sent in a batch there are (about) 10% errors in generating a corresponding PDF document when calling the mail merge method
2. In a batch of 704 messages, we saw about 8% errors
3. Here is a typical error message:

4. 2023-02-02T19:24:58.417 [Error] System.OutOfMemoryException: Out of memory.
5. at System.Drawing.Image.ValidateImage(IntPtr image)
6. at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
7. at spr䡸.᜞(Byte[] A_0)
8. at spr䒌.ᜀ(spr䞱 A_0)
9. at spr䒐.ᜀ(spr䞱 A_0)
10. …
11. at spr㆓.ᜀ(sprㅳ A_0, spr⯂ A_1)
12. at spr㆓.ᜂ(sprㅳ A_0)

13. at Spire.Doc.Document.ᜅ(Stream A_0, ToPdfParameterList A_1)
14. at Spire.Doc.Document.SaveToStream(Stream stream, ToPdfParameterList paramList)


Can you please help us identify why we are getting this exception for some of our files and how we can avoid it?


Thanks so much,
Ben

BFeldman
 
Posts: 9
Joined: Wed May 26, 2021 2:54 pm

Mon Feb 06, 2023 10:00 am

Hello,

Thanks for your inquiry.
According to the message you provided, I suggest you can increase the value of maxConcurrentSessions and maxConcurrentCalls. In addition, you can locate the document that threw System. OutOfMemoryException, then test this document individually to check whether the exception is threw when execute the function of mail merging.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 951
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc