moonpdf icon indicating copy to clipboard operation
moonpdf copied to clipboard

OpenFile throws 'System.DllNotFoundException'

Open mgnslndh opened this issue 9 years ago • 5 comments

I call OpenFile on the MoonPdfPanel and get the following exception:

An exception of type 'System.DllNotFoundException' occurred in MoonPdfLib.dll but was not handled in user code

Message

Det gick inte att läsa in DLL-filen libmupdf.dll: Det går inte att hitta den angivna modulen. (Undantag från HRESULT: 0x8007007E)

Stack Trace

   vid MoonPdfLib.MuPdf.MuPdfWrapper.NativeMethods.NewContext(IntPtr alloc, IntPtr locks, UInt32 max_store)
   vid MoonPdfLib.MuPdf.MuPdfWrapper.PdfFileStream..ctor(IPdfSource source)
   vid MoonPdfLib.MuPdf.MuPdfWrapper.GetPageBounds(IPdfSource source, ImageRotation rotation, String password)
   vid MoonPdfLib.MoonPdfPanel.LoadPdf(IPdfSource source, String password)
   vid MoonPdfLib.MoonPdfPanel.Open(IPdfSource source, String password)
   vid MoonPdfLib.MoonPdfPanel.OpenFile(String pdfFilename, String password)

I am using Nuget package version 0.3.0

mgnslndh avatar Feb 07 '16 14:02 mgnslndh

Hi,

the problem is that the native libmupdf.dll is not in the executing directory. The NuGet package you are mentioning is not from me, but as far as I can tell, there is no automatism to copy the libmupdf.dll to the output directory. You can find the libmupdf.dll in the lib-folder of the NuGet package, which should be: packages\MoonPdfLib-x86.0.3.0\lib. Include the dll in your project and set its property Copy to Output Directory to Copy Always.

reliak avatar Feb 07 '16 15:02 reliak

I tried to add dll from the packages folder and i am getting the message or warning from Visual studio

A reference to dll from the package folder could not be added make sure file is accessible and that is a valid assembly or com component

Have you faced the same issue @mgnslndh ?

NessfertIndia avatar Mar 10 '16 06:03 NessfertIndia

You can not add the dll in VS because it is a native c-dll. The solution is, as stated above, to use Copy to Output to copy the dll to the executing directory.

reliak avatar Mar 10 '16 07:03 reliak

@NessfertIndia follow instructions by reliak and it should work.

mgnslndh avatar Mar 14 '16 11:03 mgnslndh

i encountered the same question, and this cannot solve it

lannisite110 avatar May 16 '23 06:05 lannisite110