Close
dtSearch .NET Standard API 2023.02
Server.SetEnginePath Method

Specify the folder location of the dtSearch Engine DLL

public static bool SetEnginePath( string p );

The dtSearch .NET API wrapper dtSearchNetStdApi.dll, depends on the dtSearch Engine DLL dtSearchEngine.dll. In .NET applications, an unmanaged DLL dependency can be separated from the managed assembly when it executes. In most cases, this can be prevented by adding the correct dtSearchEngine.dll file to the project as a "Content" item with a "Copy if newer" action. For more information, see: Native Libraries 

If for some reason it is not possible to resolve the dependency this way, SetEnginePath provides a way to specify where the dtSearch Engine DLL is located. If used, it must be called before anything else is done using the dtSearch .NET API. 

SetEnginePath is a static method, so you can call it without creating a dtSearch.Engine.Server object. 

SetEnginePath only works under Windows. It relies on Windows-specific dynamic library loading behavior and on the LoadLibraryEx Windows API function.

When to use SetEnginePath

SetEnginePath is only needed when you cannot ensure that the dtSearch Engine DLL will be in the same folder as the .NET API wrapper when your application executes. 

If have administrative rights on the server, you can avoid the need to use SetEnginePath by by copying the dtSearchEngine library into a folder that is on the system PATH, or by adding the correct dtSearchEngine.dll file to your project as described above. 

 

How SetEnginePath works

The .NET API wrapper depends on the dtSearch Engine, but the dtSearch Engine is called using P/Invoke, so it is not needed until you actually create a API object such as SearchJob or IndexJob. If you call Server.SetEnginePath before creating any API objects, then the API wrapper can use the provided directory to load the dtSearch Engine DLL using LoadLibrary, eliminating the need for the dtSearch Engine DLL to be located using the usual DLL search path.