coolscitist
coolscitist

Reputation: 3377

Can't use libpdf.dll with Visual Studio C# project

I downloaded libpdf.dll and its dependencies from http://code.google.com/p/lib-pdf/downloads/list

Then I copied the dlls into "debug" folder within "bin" folder of project. Then, I added reference to libpdf.dll

When I run sample code:

using (FileStream file = File.OpenRead(@"D:\test\pdfs\sample.pdf")) // in file
            {
                var bytes = new byte[file.Length];
                file.Read(bytes, 0, bytes.Length);
                using (var pdf = new LibPdf(bytes))
                {
                    byte[] pngBytes = pdf.GetImage(0, ImageType.PNG); // image type
                    using (var outFile = File.Create(@"D:\test\pdfs\file.png")) // out file
                    {
                        outFile.Write(pngBytes, 0, pngBytes.Length);
                    }
                }
            }

I get the following error:

A procedure imported by 'libpdf.dll' could not be loaded. Make sure that the file is a valid .Net Framework Assembly.

How do I proceed on solving this error? How do I know which dll it is talking about??

Upvotes: 1

Views: 7194

Answers (1)

Kurubaran
Kurubaran

Reputation: 8902

startup Element MSDN

Include the following in your configuration file,

<startup useLegacyV2RuntimeActivationPolicy="true">
</startup>

Upvotes: 1

Related Questions