One solutions is a basic “tools” package that provides support functions, webparts, ribbon buttons, etc. to the other solutions. This is where PDFNet 5.9.2 is referenced (and is configured to deploy to the GAC).
Your library works fantastically, everywhere. I have timer jobs that optimize pdfs on the file system, I have ribbon buttons to join pdfs together, convert images to pdf, event handlers that optimize pdfs attached to inbound emails, etc. Spectacular.
This weekend I attempted to add to the solution a WCF service to accept pdfs as byte, optimize and return them, over a web service. Everything about the WCF part works fine right up to the point where it tries to initialize the PDFNet when it stops and complains it can’t load the file or assembly PDFNet 5.9.2… The handle is invalid.
Every other aspect of this project that requires your dll works perfectly, all in the same debug session. So the DLL is in the gac and is accessible.
Normally “handle is invalid” would lead me to believe I have a 32/64 bit issue (e.g. https://groups.google.com/d/msg/pdfnet-sdk/Op5m-2VH2ww/2qSjM8PGRzAJ), except that other components of the project that invoke the dll work fine, again in the same debug session.
Adding your DLL to the assemblies section of web.config per this article resolved it:
2. Additionally, any SharePoint code that needs to read/write temp files (e.g. The PDFNet Optimizer and Converter) needs to be run using SPSecurity.RunWithElevatedPrivileges: