login about faq

In a web application, the following error shows up when browsing to a page that instantiates a Chilkat object. Could not load file or assembly 'ChilkatDotNet4' or one of its dependencies. An attempt was made to load a program with an incorrect format.

code behind : protected void Page_Load(object sender, EventArgs e) { Chilkat.Crypt2 c = new Chilkat.Crypt2(); }

Windows7 64bit / VS2010 v10.0.30319.1 / ASP.Net v4.0.30319.272


asked Jun 20 '12 at 16:18

Matt's gravatar image


It's a 32-bit vs. 64-bit mismatch. It means you are trying to load a 64-bit .NET assembly into a 32-bit process, or the reverse (a 32-bit assembly into a 64-bit process).

Here are possible solutions:

1) Target your app for x86 instead of "Any CPU". If you do this, then your application will run as a 32-bit process regardless of the machine architecture and you may always use the 32-bit Chilkat assembly.

2) If you really need to target "Any CPU", then make sure to deploy the 32-bit Chilkat assembly w/ your app on 32-bit systems, and deploy the 64-bit Chilkat assembly to 64-bit systems.

3) If your app is running within ASP.NET or a Windows Service and you're not quite sure whether it's 32-bit or 64-bit, then install the 32-bit Chilkat assembly in the 32-bit GAC (Global Assembly Cache), and also install the 64-bit Chilkat assembly into the 64-bit GAC. The .NET runtime will automatically look in the correct GAC and will find the correct assembly.


answered Jun 20 '12 at 16:23

chilkat's gravatar image

chilkat ♦♦

I ended up creating separate IIS Application Pools, one for 32bit and a separate 64bit pool. Thanks for the education.

(Jun 20 '12 at 18:31) Matt

Also see this: http://stackoverflow.com/questions/266082/how-do-i-tell-if-my-application-is-running-as-a-32-bit-or-64-bit-application

First determine if your app is running 32-bit or 64-bit. If it's not as you thought, then this is the error. Otherwise, you're loading the wrong DLL at runtime.

(Jul 08 '16 at 10:29) chilkat ♦♦

One more comment regarding Visual Studio and IIS: "Ah! So, by default, Visual studio (this is a new computer) is not configured to use 64 bit IIS Express. You have to set it by Tools > Options > Projects and Solutions > Web Projects. There is a checkbox to enable 64b it IIS. Crazy, uh? Thanks for your help!"

(Jul 08 '16 at 10:30) chilkat ♦♦

Thanks for the suggestions.

Solved the problem 'my way': Opened the small sample project, just built to test the FTP functions of the downloaded Chilkat .Net dll.

Loaded all modules & forms from the full project into the test project. Changed the startup object, adjusted some of the libraries & everything runs just fine.

Only project renaming & deleting of the test module still needs to be done.

Have no idea why I got that error in the main project & will most likely never know.

Thanks again, Peter K


answered Jun 28 '12 at 16:57

Peter%20123's gravatar image

Peter 123

+1 for enable 64b IIS Express, this is what I have been looking for.

Tools > Options > Projects and Solutions > Web Projects. There is a checkbox to enable 64b it IIS


answered Aug 17 '16 at 11:06

jonranes's gravatar image


How do you know if you have the 32 bit or 64 bit version?


answered Feb 07 '17 at 16:34

Tvalone1's gravatar image


In your C# program, you can do this:

if (IntPtr.Size == 4)
    // 32-bit
else if (IntPtr.Size == 8)
    // 64-bit
    // Getting here is not possible..


answered Feb 08 '17 at 09:33

chilkat's gravatar image

chilkat ♦♦


For now, the best way to know which ChilkatDotNet46.dll you have is to either keep track of what you downloaded from chilkatsoft.com, or you can download both 32-bit and 64-bit and compare the DLL sizes. The larger one is the 64-bit build.

Starting with the next version of Chilkat (v9.5.0.66), I'm going to identify the bitness (32-bit or 64-bit) in the Version resource of the DLL. This way, you can right-click on the DLL and examine the properties, then go to the Details tab, and you'll see either "64-bit" or "32-bit" in the description.


answered Feb 08 '17 at 10:00

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jun 20 '12 at 16:18

Seen: 336,769 times

Last updated: Feb 08 '17 at 10:00

powered by OSQA