Skip to content

GhostScript.NET v1.2.1 Library Load issue #34

Closed

Description

@JohnVLinton

As I answered someone else's problem, mine was still only partially solved.

I'm using the library on a website that allows multiple users to upload PDF's at the same time and needs to invoke the GS DLL simultaneously. What I found was this is not possible so instead I use this solution

static lock surrounds -> raster.Open(fileStream, _version, false);

This has been working fine for 99.5% of cases but now for the first time after several months on the server I see this rare-bird 4 times in an hour for a user that I cannot replicate:

System.Exception: Module could not be loaded.
at Microsoft.WinAny.Interop.DynamicNativeLibrary..ctor(String fileName)
at Ghostscript.NET.GhostscriptLibrary..ctor(GhostscriptVersionInfo version, Boolean fromMemory)
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)

I have no idea how to replicate it and she tried later with the exact same .pdf upload and this time it works again fine.

My guess is something about the DLL not being entirely in memory correctly, or else IIS recycling and losing the static lock -- but this should be a very rare thing in production and I'm wondering if something else weird is going on with the DLL.

Activity

  1. ahmetmert commented on Apr 12, 2018

    @ahmetmert

    Did you somehow fix this issue ? After it is been used for a few month, I start constantly getting this exception

  2. JohnVLinton commented on Apr 12, 2018

    @JohnVLinton
    Author

    I believe the fix I found involves enabling 32-bit applications to run in your IIS application pool. (Or at least this is a necessary if not sufficient part of the answer.) Then recycle your pool/app. Elsewise it takes a lot of fiddling still maybe... :(

    Definitely look at trying both raster.Open(fileStream, _version, false) and raster.Open(fileStream, _version, true) and comparing performance. Often when one of these doesn't work the other does. If you open from file, lock with static lock around the region you need it open for multiple users.

    For such a popular library, it does have some weird little ghosts, if you'll pardon the pun.

  3. Krashlog commented on Mar 13, 2019

    @Krashlog

    We're getting the same errors randomly on some of our web servers. We've been using GhostScript.NET for years without any problems. We've tried enabling 32-bit applications, it seemed to work for a while but the problems came back. So, recycling the app pool seems to fix the problem temporarily, but that's not a long term solution.

    So, short of periodically recycling the app pool, any clues/ideas?

  4. jhabjan commented on Feb 4, 2021

    @jhabjan
    Contributor

    Fixed in today's v.1.2.2. release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions