This project is read-only.

Threading issue on a web server?

Jan 27, 2014 at 11:19 PM
Hello, I am trying to use Ghostscript.NET on a web server for back-end processing. It works fine under a single user, but when I kick off a process with multiple users the .StartProcessing call will fail with the following error:

An error occured when call to 'gsapi_new_instance' is made: -100

This looks to me like a threading or similar multi-user error, but I'm not sure how to resolve it. I am running GS 9.10 GPL, ASP.NET 4.5 and IIS 7. Is there something specific I need to configure for Ghostscript to make it work on a web server?

Thank you,

Here is my source code:

GhostscriptVersionInfo _gs_version_info =
GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL);
GhostscriptProcessor processor = new GhostscriptProcessor(_gs_version_info);

List<string> switches = new List<string>();
switches.Add("-sOutputFile=" + variantPath);
processor.StartProcessing(switches.ToArray(), null);
Jan 29, 2014 at 5:28 PM
Hi, sorry for the delay,

Try to create GhostscriptProcessor instance like this:

GhostscriptProcessor processor = new GhostscriptProcessor(_gs_version_info, true);

Where second parameter 'true' tells the GhostscriptProcessor to create the instance in it's own memory space. By default in your sample this parameter is set to 'false'.

Marked as answer by gerlock11 on 1/29/2014 at 12:37 PM
Jan 29, 2014 at 8:37 PM
Hi Josip, this worked great. Thank you!

I was using a workaround where I created a single instance of the processor object and stored it in Application scope, then used the lock() command to lock the processor each time it was called. While that seemed to resolve the issue I'm not sure that would be healthy long term.

Thank you again for your response.
Jan 31, 2014 at 3:37 PM
I'm glad I could help.

Workaround you made earlier is fine and will work long term if you don't need to convert multiple PDF's at a same time on a same machine.