Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module could not be loaded #111

Open
litao198610 opened this issue Apr 3, 2023 · 1 comment
Open

Module could not be loaded #111

litao198610 opened this issue Apr 3, 2023 · 1 comment

Comments

@litao198610
Copy link

when i use ghostscript.net to print pdf file,the system throw exception "Module could not be loaded",I downloaded gsdll to a local folder,Do you know what caused it? the code is following:
public static void Printpdf(string pdfFilePath,string printerName)
{
try
{
var path = "";
if (Environment.Is64BitOperatingSystem)
{
path = Path.Combine(AppContext.BaseDirectory, "GSDll/gsdll64.dll");
}
else
{
path = Path.Combine(AppContext.BaseDirectory, "GSDll/gsdll32.dll");
}
var gvi = new GhostscriptVersionInfo(path);
Ghostscript.NET.Processor.GhostscriptProcessor processor = new Ghostscript.NET.Processor.GhostscriptProcessor(gvi, true);
var switches = new List();
switches.Add("-empty");
switches.Add("-dPrinted");
switches.Add("-dBATCH");
switches.Add("-dNOPAUSE");
switches.Add("-dNOSAFER");
switches.Add("-dNoCancel");
switches.Add("-dNOPROMPT");
switches.Add("-dNOPAGEPROMPT");
switches.Add("-dPDFFitPage");
switches.Add("-dQueryUser=3");
switches.Add("-dNumCopies=1");
switches.Add("-dSubsetFonts=false");
switches.Add("-sDEVICE=mswinpr2");
switches.Add("-f");
switches.Add(Convert.ToString("-sOutputFile=%printer%") + printerName);
switches.Add(pdfFilePath);
processor.StartProcessing(switches.ToArray(), null);
}
catch (Exception ex)
{
if (System.IO.File.Exists(pdfFilePath)) { System.IO.File.Delete(pdfFilePath); }
throw new Exception(ex.Message,ex);
}
}

@ab78908
Copy link

ab78908 commented Apr 26, 2023

I have seen this error when gsdll64.dll from ghostscript native library installation got somehow corrupted. LoadLibrary Win32 function was returning error 998 ERROR_NOACCESS. Overwriting the file with fresh copy resolved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants