Last Reviewed: April 27, 2009
Article: DTS0223
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 if the way Visual Studio builds ASP.NET applications. For more information, see How to use the 64-bit version of the dtSearch Engine.
Under 64-bit platforms, .NET can try to load dtSearchNetApi2.dll as a 64-bit component instead of a 32-bit component.
dtSearchNetApi2.dll and dten600.dll are 32-bit components, so they cannot be loaded in a 64-bit process. Unfortunately, an assembly built in .NET will run by default as 64-bit under a 64-bit OS. Therefore, when you build your assembly to run in 64-bit Windows, you need to 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.
For documentation on working with corflags, see:
CorFlags Conversion Tool
http://msdn2.microsoft.com/en-us/library/ms164699(VS.80).aspx
For ASP.NET applications, this article explains how to configure 64-bit IIS to run 32-bit processes:
If the ASP.NET application is called as a 32-bit process, ASP.NET should build it as a 32-bit executable, and then dten600.dll and dtSearchNetApi2.dll will load correctly.