0

I have a C#/MVC website for uploading PDFs and when multiple browser instances try to upload at the same time, using Ghostscript.Net v 1.2.1, I get the following error:

Ghostscript.NET.GhostscriptAPICallException: An error occured when call to 'gsapi_new_instance' is made: -100 at Ghostscript.NET.Interpreter.GhostscriptInterpreter.Initialize() at Ghostscript.NET.Interpreter.GhostscriptInterpreter..ctor(GhostscriptVersionInfo version, Boolean fromMemory) at Ghostscript.NET.Viewer.GhostscriptViewer.Open(String path, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory) at Ghostscript.NET.Viewer.GhostscriptViewer.Open(Stream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory) at Ghostscript.NET.Rasterizer.GhostscriptRasterizer.Open(Stream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)`

It breaks here:

private Ghostscript.NET.GhostscriptVersionInfo _version = Ghostscript.NET.GhostscriptVersionInfo.GetLastInstalledVersion(Ghostscript.NET.GhostscriptLicense.GPL | Ghostscript.NET.GhostscriptLicense.AFPL, Ghostscript.NET.GhostscriptLicense.GPL); 

using (var raster = new GhostscriptRasterizer())
{               
    raster.Open(fileStream, _version, false);
}

on the Open. This code is called from within a function called by a async Task<ActionResult>. I wonder if the async is somehow breaking it. On the GhostScript site, the closest related answer I could find is to make sure I Close()/Dispose() prior instances -- however this is not my issue as the problem is concomitant instances in different browser sessions calling down into the same .dll (which does have Everyone permissions in IIS).

There is no static variables in reference to any of this, and it happens off an originating HttpPost.

John Linton
  • 199
  • 1
  • 13
  • Yes that helped some, but I still needed a static lock to control one-time access only to the DLL. I originally tried to thank you but didn't have standing to leave comment yet... – John Linton Oct 12 '17 at 12:20
  • Sorry yeah I edited the above (getting used to site). – John Linton Oct 12 '17 at 12:23

1 Answers1

3

As per https://github.com/jhabjan/Ghostscript.NET/issues/10 , you likely need to change:

raster.Open(fileStream, _version, false);

to:

raster.Open(fileStream, _version, true);
mjwills
  • 23,389
  • 6
  • 40
  • 63