Resolving 'BadImageFormatException' when using PDFNet on 64-bit web server.

Q: I am currently testing out your new PDFNet WebViewer Sample project
from PDFNet SDK. I'm running into some issues with the following
project: WebViewerStreamingCS_2008.

1. I've setup visual studio to use CassiniDev as suggested.
o When running the project in VS 2008 using CassiniDev I get an error
(see attached CassiniDev_Error.png)
2. I’ve tried using IIS and have setup virtual directory, and
converted the virtual directory to an application
o With this setup I get an asp.net stack trace (see attached
IIS_Application_Error.jpg)

Looks like I need some additional help setting up this project.

Any help would be appreciated,
-----------------
A: The problem is that PDFNet DLL and the web server process are
incompatible (32 vs 64 bit).

According to:
https://groups.google.com/group/pdfnet-sdk/t/3a9e66fb6547db0c/7858192b1f10493a

you could use 32 bit version of PDFNet with IIS as follows…

... in your IIS 2008 R2 Web Server application pool, set the Identity
to "LocalSystem" (for both .NET 2.0 and .NET 4.0). Also, make sure to
set the "Enable 32-Bit Applications" to "True".

Q:

I've made the changes and PDFNet now works on the web server, however 
I am now getting the following js error/alert message: 
 
"Wrong signature in local header: 1836345404"

A:

You are getting the error in JavaScript because the URL for the document request is not correct. The WebViewerStreaming sample is written so that it can run from Visual Studio without any modifications whatsoever. In your case however, because you are running the sample at “http://localhost/PdfWebViewer/”, the correct URL for the document conversion request will be: “http://localhost/PdfWebViewer/ConvertAndStream.aspx”. As mentioned, our samples are designed to ran out of the box, thus (without modifications), the sample sends requests to “http://localhost/ConvertAndStream.aspx”.

What you can do in this case is to open the Index.aspx file, and modify the URL for the document conversion request (the initialDoc parameter) accordingly - in your case, you may want to change it to “/PdfWebViewer/ConvertAndStream.aspx”.

If you are using IIS on Azure, and you’re seeing this “BadImageFormatException” (“Could not load file or assembly ‘PDFNet’ or one of its dependencies. An attempt was made to load a program with an incorrect format” ) when using IIS on Azure, you may need to select the correct architecture:

Hi Aaron,
I have done as you mentioned above but unfortunately “Platform” is not available in my Azure web app service. My Azure account is a free test account and to use this feature I need to upgrade. How do you want to instruct us to proceed in my situation? or do I have to upgrade my Azure to a paid account?

If the only option is to upgrade, what is the recommended pricing tier/app service plan to use that enables the “Platform” option?

Hello Suren,

Since Azure is not our service, we are not able to provide advice regarding its options for free or paid subscriptions.

That said, we do provide some advice when running WebViewer Server on Azure. In that case, we recommend using a Linux VM or the Container Instances service:

https://www.pdftron.com/documentation/web/guides/deployment-options/webviewer-server-on-azure/

WebViewer Server is an easier way to deploy WebViewer than building your own conversion queue (https://www.pdftron.com/documentation/web/guides/deployment-options/webviewer-server).