Visual-studio – How to compile x64 asp.net website

64-bitasp.netchilkatiisvisual studio

I'm trying to compile (using Visual Studio) an ASP.Net website with the Chilkat library. The compilation fails due to this error:

Could not load file or assembly 'ChilkatDotNet2, Version=9.0.8.0,
Culture=neutral,
PublicKeyToken=eb5fc1fc52ef09bd' or
one of its dependencies. An attempt
was made to load a program with an
incorrect format.

I've been told that this error occurs because of platform noncompliance.

The weird thing is that although the compilation fails, the site works once accessed from a browser. My theory is that the IIS compilation uses csc.exe compiler from the Framework64 (64 bit) folder while the Visual Studio uses csc.exe compiler from the Framework (32 bit) folder. If this is acually it, how can I configure my Visual studio to run with the 64 bit compiler for ASP.Net sites?

This is my current development configuration:

  • Windows 7 (x64).
  • Visual Studio 2008 Pro (x86 of course…).
  • Chilkat library (x64)
  • IIS/Asp.net (x64).

Best Answer

The Why:
Your website (the managed portion, likely all of it non-third party) isn't compiled in 32 or 64-bit mode, at least not in the way you're thinking. The difference is thatWebDevServer.exe (A version of Cassini) that visual studio uses for it's webserver is exclusively 32-bit. So, it only loads 32-bit compatible DLLs.

IIS on a 64 bit machine can run in either 32 or 64 bit mode (defaults to 64-bit), depending on the configuration settings, so it has no trouble loading up your application.

Solution: Unfortunately, there aren't a lot of options here, I asked the same question a while ago. Your best bet is to use IIS for debugging. You set it up like this:

  • Web Project > Settings
  • "Web" Tab
  • Under Servers, select Use Local IIS Web Server