Ghostscript.NET icon indicating copy to clipboard operation
Ghostscript.NET copied to clipboard

Module could not be loaded

Open litao198610 opened this issue 2 years ago • 1 comments

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

litao198610 avatar Apr 03 '23 06:04 litao198610

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.

ab78908 avatar Apr 26 '23 21:04 ab78908