How do I target .NET Framework v 4 with PDFNet ?


I am testing the demo version of PDFTron SDK for .NET to see if it fits my purpose. I’ve ran the sample program included in the download package: “PDFNet\Samples\ElementBuilderTest\CS\ElementBuilderTestCS.sln”. It runs fine as is, with the Target framework set to “.NET Framework 2.0”. But if I change the Target framework to “.NET Framework 4”, the example crashes on this line “doc.Close();”

This is the error message: FatalExecutionEngineError

The runtime has encountered a fatal error. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Another error appears after the first error: AccessViolationException was unhandled

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
It seems like the source runs fine up to .NET Framework 3.5, but no on 4.0.

Would you mind letting me to know how I can run it properly on .NET 4.0 framework?


If you want to target .NET v4 or higher, you should use or

You can download these from:

Also please make sure to call PDFNet.Initialize() before any other PDFNet related calls.