> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Different Ways to Load the Engine Object

There are three ways to load the [**Engine**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine.md) object in ABBYY FlexiCapture 12 SDK. Each of the loading methods has its own specifics affecting the use of the object in different circumstances. The first two methods are most suitable for use in interactive applications which are not intended for simultaneous processing of multiple requests. The third method is most suitable for server solutions.

## Loading FCEngine.dll manually and working with “naked” interfaces

This is the standard method to load the **Engine** object that was also used in old versions of ABBYY FlexiCapture Engine. To get a reference to the **Engine** object, you should do the following:

* call the [**GetEngineLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/getengineloader.md) exported function to create the [**EngineLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/iengineloader.md) object
* set up all the necessary parameters using the [**EngineLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/iengineloader.md) object properties
* call the [**GetEngine**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/iengineloader-getengine.md) method of the [**EngineLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/iengineloader.md) object and receive the reference to the **Engine** object.

This object loading method is described in detail in the Tutorial, [Step 1: Load FlexiCapture SDK](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/engine-loading.md).

<table width="100%"><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td><ul><li>Results in maximum performance.</li><li>Easy access to any licensing type.</li><li>Does not require registration of FCEngine.dll.</li></ul></td><td><ul><li>Imposes restriction on working with multi-threaded applications (see [Using ABBYY FlexiCapture SDK in Multi-Threaded Server Applications](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/usinginserverapplications.md)).</li><li>When working with high-level languages like .NET, you will have to use low-level API to load dynamic libraries and call functions published in them.</li></ul></td></tr></tbody></table>

## Loading the Engine object by means of COM into the current process

The Engine is loaded as an in-process server into the same process where the application is running. The **Engine** object is loaded using the [**InprocLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/inprocloader.md) object, which implements the [**IEngineLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/iengineloader.md) interface.

Please note that you must keep the reference to the loader object until you finish working with the **Engine**. You can then call the **Unload** method of the loader object to deinitialize the **Engine**, and then destroy the loader object.

<table width="100%"><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td><ul><li>All ABBYY FlexiCapture SDK objects are completely thread-safe and can be created and used in different threads.</li><li>When working from the Мain STA apartment, performance is the same as when working with the naked interfaces. When accessing from different threads, some marshalling losses may occur, which are negligible in most scenarios.</li></ul></td><td><ul><li>Registration of FCEngine.dll is required when installing the final application on an end user's computer.</li></ul></td></tr></tbody></table>

> [accordion] C# code
>
> ```csharp theme={null}
> IEngineLoader engineLoader = new FCEngine.InprocLoader();
> engineLoader.CustomerProjectId = GetCustomerProjectId();
> engineLoader.LicensePath = GetLicensePath();
> engineLoader.LicensePassword = GetLicensePassword();
> engine = engineLoader.GetEngine();
> try {
>      ...
> } catch {
>      ...
> } finally {
> // We can unload it when it is no longer needed
> engineLoader.Unload();
> }
> ```

To register FCEngine.dll when installing your application on an end-user computer, use the following command line:

```bat theme={null}
regsvr32 /s /n /i:"<path to the Inc folder>" "<path to FCEngine.dll>"
```

## Loading the Engine object by means of COM into a separate process

The Engine is loaded as an out-of-process server into a separate process. The **Engine** object is loaded by means of the [**OutprocLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/outprocloader.md) object, which implements a [**IEngineLoader**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/iengineloader.md) interface.

Please note that you must keep the reference to the loader object until you finish working with the **Engine**. You can then call the **Unload** method of the loader object to deinitialize the **Engine**, and then destroy the loader object.

<table width="100%"><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td><ul><li>All ABBYY FlexiCapture SDK objects are completely thread-safe. Each instance of the Engine runs in a separate process parallel to the others.</li></ul></td><td><ul><li>There are some small marshalling losses.</li><li>Registration of FCEngine.dll is required when installing the final application on an end user's computer.</li><li>When working under accounts with limited permissions, the necessary permissions must be granted.</li><li>It is impossible to access a page image as HBITMAP without marshalling.</li></ul></td></tr></tbody></table>

> [accordion] C# code
>
> ```csharp theme={null}
> IEngineLoader engineLoader = new FCEngine.OutprocLoader();
> engineLoader.CustomerProjectId = GetCustomerProjectId();
> engineLoader.LicensePath = GetLicensePath();
> engineLoader.LicensePassword = GetLicensePassword();
> engine = engineLoader.GetEngine();
> try {
>     ...
> } catch {
>     ...
> } finally {
> // We can unload it when it is no longer needed
>  engineLoader.Unload();
> }
> ```

> [!NOTE]
>
> * Account permissions can be set up using the **DCOM Config** utility (either type **DCOMCNFG** in the command line, or select **Control Panel > Administrative Tools > Component Services**). In the console tree, locate the **Component Services > Computers > My Computer > DCOM Config** folder, right-click **ABBYY FlexiCapture 12 SDK Loader (Local Server)**, and click **Properties**. A dialog box will open. Click the **Security** tab. Under **Launch Permissions**, click **Customize**, and then click **Edit** to specify the accounts that can launch the application. Note that on a 64-bit operating system the registered DCOM-application is available in the 32-bit MMC console, which can be run using the following command line: "mmc comexp.msc /32"
>
> * To register FCEngine.dll when installing your application on an end-user computer, use the following command line:
>
>   ```bat theme={null}
>   regsvr32 /s /n /i:"<path to the Inc folder>" "<path to FCEngine.dll>"
>   ```
>
> * We recommend that you use a Network license both for debugging your server application and for running it.

Additionally you can manage the priority of work processes and control whether their parent process is alive and terminate if it is not. Use the [**IWorkProcessControl**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/iworkprocesscontrol.md) interface.

## Comparison table

The table below sums up the characteristics of the three loading methods:

| Characteristics | Naked interfaces | In-process server | Out-of-process server |
| - | - | - | - |
| Works without proxy (no marshalling losses) | Yes | There are limitations | No |
| Works in multi-threaded applications | There are limitations | Yes | Yes |
| Parallel running processes are possible (for server solutions) | No | No | Yes |
| No registration of FCEngine.dll required | Yes | No | No |
| No running permissions must be set up | Yes | Yes | No |
| Objects can be created using the **new** operator. Works from scripts. | No | Yes | Yes |
| Ability to access a page image as HBITMAP | Yes | Yes | No |
| Works in a separate process (fail-proof, recycling) | No | No | Yes |

## Using from a 64-bit process

If you are going to use ABBYY FlexiCapture SDK from a 64-bit process (e.g. ASP.NET on 64-bit servers), we recommend that you use the way of loading FlexiCapture SDK into a work process.

## See also

[Using ABBYY FlexiCapture SDK in Multi-Threaded Server Applications](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/usinginserverapplications.md)
