views:

488

answers:

2

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).
+1  A: 

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
Nick Craver
I'm not using the Visual Studio's web server abilities (the dynamic port web server with the tray icon) - only IIS. I have IIS on my developing environment.
Eran Betzalel
@Eran - So even in debug, you're configured as with my answer, for it to debug/launch via IIS?
Nick Craver
Yes I use only IIS (even in debug).
Eran Betzalel
A: 

I realized that there is no way Visual Studio will be able to compile the website with the x64 DLL, because Visual Studio is an x86 application. The IIS works fine with the DLL, because I installed it's x64 version.

The solution is to put them both (the x64 & x86 DLLs) in the GAC and let each application dynamically decide when to use the x64 or x86 DLL (of course you'll have to reference the GAC DLL in your project).

Eran Betzalel