1

I am trying to run an existing solution on my local machine but every time I try to run it I get the error below [image below].

Could not load file of assembly 'HtmlToPdfBuilder' or one of its dependencies. An attempt was made to load a program with an incorrect format'

I am unsure if it is relevant but it also gives information about partial binding

WRN: Partial binding information was supplied for an assembly

I can't find where the dll "HtmlToPdfBuilder" came from so I can't check if there is a different version. I have got my project set to compile against "Any CPU", but have tried setting it to x64 and x86 and I have also tried setting "Enable 32-bit Applications" to both true and False in IIS.

The dll was sitting in a folder outside the project and referenced, I have tried moving it into the project and referencing it (just incase).

The exact same project works on someone else's machine and we have tried comparing but can't see any differences in set up.

I am running Visual Studio 2012 and this is a VB.NET project.

enter image description here

Update

This is also running on a server

  • I have tried matching my IIS and Website settings
  • I have tried copying all the dlls from the server down to my local machine but still get the same error
  • I have also copied all my local dlls up to the server and the site still runs fine there
  • I have also matched the webconfigs and the only difference is that on the server entity framework is set as Version=4.3.1.0 and locally it is Version=6.0.0.0
Bex
  • 4,898
  • 11
  • 50
  • 87

2 Answers2

2

It seems like you are trying to use a 32bit dll on a 64bit application (or viceversa) so here is what you should use.

  1. Open the Visual Studio Command Prompt and type "corflags [pathTo]/[your assembly]", this will tell you the architecture so you can change/verify you have the proper dll.
  2. On Visual Studio go to the reference properties and check where is it being retrieved. Then change the refresh path to your dll path accordingly and also set the copy local to true.
  3. Rebuild and run.
  4. If it is also running on IIS, set Enable 32-bit Applications to true.
Slukad
  • 62
  • 5
  • I have tried this and got the following: Version : v2.0.50727 CLR Header: 2.5 PE : PE32 CorFlags : 0x3 ILONLY : 1 32BITREQ : 1 32BITPREF : 0 Signed : 0 I tried changing 32BitReq to 0 but it made no difference. Is this what you meant? Never used this before so don't really understand. – Bex Jun 16 '15 at 15:55
  • That only means that DLL is 32bit. So, after knowing that, a quick fix would be simply using a 64bit version of that dll or check that all projects and dlls that use HtmlToPdfBuilder are built on 32 bits or ANY CPU – Slukad Jun 16 '15 at 16:19
  • I set all the projects to build to 32bit and it made no difference and I have no idea where the htmltopdfbuilder dll comes from so I can't find a different one.. what I don't understand is why it works on another machine! What am I missing? – Bex Jun 17 '15 at 08:01
1

Here's what I finally did to fix this:

  • Re-registered .net and IIS at the command prompt

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -i

  • Created a new application pool (as messed with so many settings)
  • Set enable 32-bit on the application pool
  • Restarted IIS

I cannot explain why this works, as not got any problems with any other sites, but as it did I thought I'd share incase it helps anyone else.

Bex
  • 4,898
  • 11
  • 50
  • 87