Search code examples
c#windowsservicevisual-studio-2013chilkat-email

An attempt was made to load a program with an incorrect format. ChilkatDotNet4. Not fixed by usual methods


I'm getting the 'An attempt was made to load a program with an incorrect format' error when trying to run a program using 32 bit version of the chilkatdotnet4 dll.

I have tried this: (setting the IIS app pool to allow 32 bit programs): I get a "An attempt was made to load a program with an incorrect format" error on a SQL Server replication project (Installed IIS first) And the answer further down the page by Mazhar Karimi.

This: (changing the cpu target within VS): Change target CPU settings in Visual Studio 2010 Express

This: (placing the chilkat library into the GAC for 32 bit!): http://www.chilkatforum.com/questions/114/64bit-could-not-load-file-or-assembly-chilkatdotnet4-or-one-of-its-dependencies-an-attempt-was-made-to-load-a-program-with-an-incorrect-format

And finally, going into the .csproj file itself in notepad and changing the Platform Target (and anything else that mentioned platform) into x86.

Edit: I have also tried going into the .dll properties and clicking 'unblock'.

After every change I have saved, built, uninstalled and reinstalled my program (c# windows service)

I am STILL getting this error! Any ideas?


Solution

  • After changing your windows service to x86 this will change the build directory to

    ..ProjectName\bin\x86\debug

    Make sure your windows service is pointing at this directory otherwise you will be running your old (any CPU) version of the service.

    If you service is not pointing at this x86 directory, uninstall and reinstall the service for the new directory