Last Reviewed: August 6, 2013
Applies to: dtSearch Engine .NET API
"An attempt was made to load a program with an incorrect format" means that you are trying to load a DLL that is mismatched with the platform. Specifically, there is a 32-bit vs. 64-bit issue.
For information on using the 64-bit version of the dtSearch Engine, see How to use the 64-bit version of the dtSearch Engine.
If you get this error using the 64-bit version of the dtSearch Engine API, set your .NET project's "Platform Target" (in the Build tab of the project Properties) to x64 instead of "Any CPU".
For ASP.NET applications, you may need to set up the project to conditionally use either the 32-bit or the 64-bit version of the dtSearch .NET API, depending on the environment, because of the way Visual Studio builds ASP.NET applications. For more information, see How to use the 64-bit version of the dtSearch Engine.
To use the 32-bit version of the dtSearch Engine on a 64-bit server, you can set some flags in the .exe to let .NET know to run the assembly as 32-bit and not 64-bit.
One way to do this is to change the Platform Target (in the Build tab of the project Properties) to x86 instead of "Any CPU".
Alternatively, you can use corflags.exe (a utility included with the .NET SDK) to set ILONLY- and 32BIT+ on your assembly.
If the application is running in 64-bit IIS, the application pool will also have to be configured to run 32-bit applications.