System.AccessViolationException when debugging x86 C# Console Application
<p>My client uses a third party tool (PDFLib) for dynamic PDF generation. There is an x64 version of the DLL that runs on a website and an x86 version that runs on a background processor which is a 32-bit console application written in C#. It must be a 32-bit console application because the client VMs that the application runs on are 32-bit.</p>

<p>My local machine is a 64-bit machine with Windows 8.1 and I am running Visual Studio 2013 Professional although I have also tried Visual Studio 2015 Professional.  The solution targets .Net Framework 4.5.1. The relevant code is below.</p>

<pre><code>PDFlib p = new PDFlib
p.set_parameter("errorpolicy", "return");
p.set_parameter("license", "my_license");

if (p.begin_document("", "") == -1) 
{
    //some error handling
}
</code></pre>

<p>At the p.begin_document call I receive a System.AccessViolationException.  I tried setting my Solution Platform to x86.  I have tried targeting framework 4.5.2.  I have put it back to 4.5.1 and uninstalled later versions of the framework. I have restarted my machine for each of these changes. None of this has had any affect.</p>

<p>This does not happen when debugging the x64 version in the web project. This does not happen in the compiled version of the x86 Console Application. This <strong>only</strong> happens when <strong>debugging</strong> the x86 Console application. What can I do to avoid this error while debugging?</p>