Chilkat .NET for x64 (64-bit Windows)

The “An attempt was made to load a program with an incorrect format.” indicates that your program attempted to load a win32 assembly on an x64 Windows OS, or the reverse.

There is a separate Chilkat .NET assembly also named ChilkatDotNet2.dll for 64-bit Windows.  It may be downloaded at: http://www.chilkatsoft.com/downloads.asp This is for the 2.0/3.5 (or greater) Framework.  There is no x64 support for the .NET 1.0/1.1 Framework.

If you are developing on a 32-bit platform, but you need to deploy to a 64-bit platform, make sure that Visual Studio does not automatically copy the win32 ChilkatDotNet2.dll to the x64 target computer.  Your project may select “Any CPU” for it’s target platform, but you must deploy the correct ChilkatDotNet2.dll to the target computer.

Important: The 32-bit ChilkatDotNet2.dll can actually be used on both win32 and x64 systems, however, the EXE that loads the DLL (i.e. assembly) must be running as a 32-bit app. If you write a .NET application and target “Any CPU”, then it will run as a 64-bit application on an x64 computer, and therefore the x64 build of ChilkatDotNet2.dll would be required. However, if you target “x86” instead of “Any CPU”, then your application will run as a 32-bit app and the win32 build of ChilkatDotNet2.dll can be used on both 32-bit and 64-bit systems.

Beware of Version Mismatch: The version of the x64 Chilkat assembly must also match the version referenced by your Visual Studio project.  Otherwise you’ll get an assembly load-time error indicating a version mismatch.

Conditional Deployment: The Visual Studio Setup & Deployment project (.msi) is capable of conditional deployment.  This means you may include both win32 and x64 versions of ChilkatDotNet2.dll in your .msi, and the correct one is installed depending on the platform where it is run.  For more information:  MSI Conditional Deployment.

Windows Services: When using ChilkatDotNet2.dll from a Windows Serivce, the Chilkat assembly may need to be installed in the Global Assembly Cache (GAC).  This this blog post:  Using Chilkat x64 .NET Assembly in a Windows Service.

ClickOnce Deployment: See this blog post about x64 ClickOnce deployment.

GAC: Another solution is to put both x86 and x64 ChilkatDotNet2.dll’s in the GAC and let it decide when to use the x64 or the x86.