.NET Assembly Incorrect Format Error

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

The “incorrect format” error is a 32-bit vs. 64-bit mismatch.  It means the application is 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).

Possible solutions are:

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.


NOTE: If this error occurred while trying to establish an FTP data connection, also see this: http://cknotes.com/?p=282

A WSAEWOULDBLOCK error when trying to establish a TCP/IP socket connection indicates one of the following conditions:

  1. A firewall at either the client or server side is blocking the connection.
  2. There is no server listening at the remote host:port to accept the connection
  3. Some other software, such as an anti-virus or anti-spyware program is blocking the connection.
  4. The server was too slow in accepting the connection.  Increase the value of the ConnectTimeout property.

You may open a DOS prompt and try to telnet to the remote host:port to test connectivity. This page provides more information: WSAEWOULDBLOCK

Note: It is impossible for the client to distinguish between any of the cases described above.  It’s similar to if you were knocking on a door and nobody answers — you have no information — you don’t know if the person simply chose not to answer the door, if the person is not home, or if the person simply cannot hear the knocking.  In all cases, the client’s knowledge is the same: there is no response and you have to decide how long you’re willing to wait…

Error: This application has failed to start because the application configuration is incorrect. Reinstalling application may fix this problem.

This error message is usually an indication that the VC++ runtime is missing on a system.

Downloading and installing the Microsoft VC++ runtime that matches the version you need will fix this problem.  To find the redistributable at microsoft.com, Google using this search string “visual c++ redistributable 2005”.  Substitute “2008”, “2002”, or “2003” for different versions…

For example, one recent Chilkat customer had this error message in Java:

java.lang.UnsatisfiedLinkError: C:\temp\new\chilkat.dll: This
application has failed to start because the application
configuration is incorrect. Reinstalling the application may fix this problem

The Chilkat modules/libs for Java, Perl, Python, and Ruby are compiled using Visual C++ 2005 (not SP1), so you would need the runtime for that version (i.e. VC++ 8.0).

This is the same error message in Czech:

Spustení této aplikace se nezdarilo, protoze konfigurace není správná. Tyto potíze lze pravdepodobne vyresit opakovanou instalací aplikace.

Invalid class string / Invalid ProgID

This note applies to the instantiation of ActiveX components (not .NET assemblies).

If a call to CreateObject (VBScript) or Server.CreateObject (ASP) or sp_OACreate (SQL) fails with the following errors:

Invalid class string

Invalid ProgID

It indicates that the ActiveX has not been registered via regsvr32 on the computer, or the registry permissions on the ProgID key prevent the object from being created.

To register, open a MS-DOS command prompt and type:

c:\> regsvr32 c:\path\ChilkatSomething.dll

Where “ChilkatSomething.dll” is the filename of a Chilkat ActiveX DLL.

The DLL may be located in any directory.  (It does not need to be placed in Windows\system32.)  The important point is that once registered, the DLL’s physical location should not be changed.

This error might also be the result of insufficient permissions for the ProgID registry key.  If you know the component has been registered via regsvr32, run regedt32 and check the permissions on the HKEY_CLASSES_ROOT\ProgID, where ProgID is a string such as “Chilkat.Ftp2” or “Chilkat.Ssh”.  The full set of ProgID’s may be found here:  Chilkat ProgID’s for CreateObject Open the registry key, select Permissions from the Edit menu and grant the “Everyone” account full control.

FTP – WSAECONNRESET An existing connection was forcibly closed by the remote host.

One of the most common problems with FTP data transfers (including downloading directory listings) has to do with Passive vs. Active mode. Depending on your client/server/firewall situation, it’s probable that only one of the two modes will work (Active or Passive). Normally, if you choose the mode that doesn’t work, the data connection is blocked and you get a “WSAEWOULDBLOCK” error — meaning the TCP/IP data connection could not be established.

One Chilkat customer reported getting a WSAECONNRESET error when in Active mode. Switching to Passive mode fixed the problem.

In summary, if your FTP mode is Active (meaning the Passive property is set to false or 0) and you see the WSAECONNRESET error when trying to upload or download a file, or when trying to retrieve a directory listing, switch the mode to Passive and re-try.