Ghostscript weird lock on dll (An error occured when call to 'gsapi_new_instance' is made: -100)

末鹿安然 提交于 2019-12-11 08:36:54

问题


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.


回答1:


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);


来源:https://stackoverflow.com/questions/45214870/ghostscript-weird-lock-on-dll-an-error-occured-when-call-to-gsapi-new-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!