Wednesday, October 13, 2010

Visual Studio debugger may run 32-bit on 64-bit Windows

I discovered something while testing a component called ABCpdf from WebSupergoo. I have 64-bit Windows 7 Home Premium, so I donwloaded the 64-bit version of ACBpdf. I created a .NET 3.5 web site and attempted to instantiate the component like this:

WebSupergoo.ABCpdf7.Doc doc = new WebSupergoo.ABCpdf7.Doc();

When I pressed F5 in Visual Studio 2008 to start debugging, a runtime error resulted:

The type initializer for 'WebSupergoo.ABCpdf7.Internal.ManagedInvoke' threw an exception.

I found the explanation on WebSupergoo's support site (although they describe a different symptom: "I see the exception "Unable to load DLL 'ABCpdfCE7.dll': The specified module could not be found.")

It turns out that Visual Studio's debugger may run as a 32-bit application, even on 64-bit Windows.

By creating an IIS 7 website that points to my source code folder, and running it that way, it ran 64-bit, and the problem was solved.

Interestingly, when I created a Windows Forms application and ran that using the Visual Studio debugger, that worked without error as well.

WebSupergoo suggests a good trick for determining whether your .NET website or appllication is running 32-bit: Output the value of IntPtr.Size. If it is 4, rather than 8, your application is running in a 32-bit process.

4 comments:

  1. Thank you!!! This helped me a lot, I've been working on this for 2 days now....

    ReplyDelete
  2. In ABCpdf version 7 the core engine is named ABCpdfCE7.dll for both 32 and 64-bit.

    The names have been changed in version 8 to allow 32-bit and 64-bit installations to run side-by-side.

    So, the exception message will read either...
    "Unable to load DLL 'ABCpdf8-32.dll", or
    "Unable to load DLL 'ABCpdf8-64.dll'.

    ReplyDelete
  3. i have 64-bit machine using it for the development and i use abcpdf7 product ,what should i install in the customers machines to deploy the setup for visual basic project, since the customer machine could be 32 or 64 bit ?
    how could i use my code to be usable when installing the project in 32 and 64 bit customers machines ?

    can i configure my vb project to use abcpdf in both 32 and 64 bit machine when installing it in other machines ?
    how to solve these issues ?

    thank you for your help

    ReplyDelete
  4. If you are using IISexpress, check where are really aplicationhost.config seeking that dlls.
    VS always (by now) works in 32 bit mode.

    ReplyDelete