tuespetre / TuesPechkin

A .NET wrapper for the wkhtmltopdf library with an object-oriented API.
326 stars 116 forks source link

memory is corrupt problem #174

Open coder3408 opened 6 years ago

coder3408 commented 6 years ago

Hello to all,

We have a multi-threaded application that is running on the server as a service. There are 5 different threads running at the same time in the same application.

Our problem is, we are sometimes having the following error.

2018-10-03 10:01:04.9511 Error DocumentActionLibrary.EmailingActions+<>cDisplayClass9_0.b4 T||UUID=xxxxxxxxxxxxxxxxxxxxxxxxxxx invoice, Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

After that error, application stops. Then we start the service manually. Then it runs normally again.

We are using the following TuesPechkin dll's

Name : TuesPechkin Description : .NET wrapper for wkhtmltopdf; supports 32-bit, 64-bit, multi-threaded and IIS environments. Runtime version : v2.0.50727 version : 2.1.1.0

Name : TuesPechkin.Wkhtmltox.AnyCPU Runtime version : v2.0.50727 version : 0.12.4.1

Server Info :

Microsoft Windows Server 2016 Version 1607 64 bit

Development source: Visual Studio 2016 - C#

Is there any idea please...

Thanks...

tloy1966 commented 6 years ago

You can use 5 threads, but make sure you have allocated a singleton IConvert

If Start 5 thread at the same time, you can lock it

public static IConverter GetIisHostedConverter() { lock (Locker) { if (_iisConverter == null) { var tempFolderDeployment = new TempFolderDeployment(); var winAnyCpuEmbeddedDeployment = new WinAnyCPUEmbeddedDeployment(tempFolderDeployment); var pdfToolset = new RemotingToolset(winAnyCpuEmbeddedDeployment); _iisConverter = new ThreadSafeConverter(pdfToolset); } return _iisConverter; } }