How to add PDFsharp lib in C#?

Royson picture Royson · Dec 2, 2009 · Viewed 51.4k times · Source

I am new to C#.net, I downloaded PDFsharp lib. But how to add this lib to our project?
My project is to create a PDF file. Please provide me step by step instructions. After unziping it has 32 folders.
I tried by coping it in my project folder, but same errors come.

"The type or namespace name 'PdfSharp' could not be found (are you missing a using directive or an assembly reference?)"

Answer

user156862 picture user156862 · Dec 2, 2009

If you wish to use this library you need to add a reference to the assembly (dll) that contains the library. To add references simply right click on your project in solution explorer and select add reference, you will then have a tabbed dialog box that allows you to add references to dlls in the GAC, other projects in your solution or browse to dlls located anywhere on your PC.

All the folders you see are the source code and sample projects that show you how to use the library. If you open the "BuildAll-PdfSharp.sln" which is contained in the root of the code directory you will be able to build PDFSharp and get the dll. It will be in the folder user code PdfSharp\bin

Once you have the dll you can add it to your solution by browsing to the location of the dll on disc. When I add third party libraries to my project I have a lib folder at the root of my working folder where all the dlls are placed. References to these in the project files then use relative paths and will be available to anyone else working on the project when they get the latest from your source repository.