> ## 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.

# Using ABBYY FineReader Engine in .NET Core

<Note>
  This topic applies to FRE for Windows .
</Note>

To run your .NET Core application in different operating systems and containers, ABBYY FineReader Engine provides you with the ready-to-use .NET Core wrapper for the Engine library. This wrapper allows you to directly access the ABBYY FineReader Engine API, which is the same for all platforms with some minor exceptions. One notable limitation is that objects implementing IEngineLoader are not available on Linux (See [Differences between ABBYY FineReader Engine 12 for Windows and for Linux](/fine-reader/engine/specifications/differences-between-abbyy-finereader-engine-for-windows-and-linux) for the full list of differences).

<Warning>
  In this release, the .NET Core wrapper does not support working with [InprocLoader](/fine-reader/engine/api-reference/engine-loaders/inprocloader) and [OutprocLoader](/fine-reader/engine/api-reference/engine-loaders/outprocloader) objects.
</Warning>

To use your application in containers, include it with .NET Core Runtime in the container image. See details for deploying ABBYY FineReader Engine in Docker container in [Running ABBYY FineReader Engine 12 inside a Docker container](/fine-reader/engine/distribution/distribution-windows/running-abbyy-finereader-engine-12-inside-a-docker-container).

## Adding ABBYY FineReader Engine library to a .NET Core project

ABBYY FineReader Engine includes the FREngine.DotNet.Interop.dll file, which contains the .NET Core wrapper for FineReader Engine. You can find this file in the Bin or Bin64 folder of the installation folder. You should add FREngine.DotNet.Interop.dll to the dependencies assembly in your project and redistribute it with your ABBYY FineReader Engine-based application.

<Warning>
  The only supported version of .NET Core is 6.
</Warning>

## Loading and unloading ABBYY FineReader Engine

To initialize the [Engine](/fine-reader/engine/api-reference/engine-object-iengine-interface) object, set the path to FREngine.dll with the SetFREnginePath method of the static FREngine class, then use the [InitializeEngine](/fine-reader/engine/api-reference/functions/initializeengine-function) function of the same class. To unload the Engine object, use the [DeinitializeEngine](/fine-reader/engine/api-reference/functions/deinitializeengine-function) function.

<Accordion title="C# code">
  ```csharp theme={null}
  // Specify the path to the ABBYY FineReader Engine Library (freRootPath)
  // before initializing
  FREngine.FREngine.SetFREnginePath ( freRootPath );
  // Loading the Engine object
  engine = FREngine.FREngine.InitializeEngine( customerProjectId, licensePath, licensePassword, "", "", false );    
  ...
  // Unloading the Engine object
  if ( engine == null )
  {
     // Engine was not loaded
     return;
  }
   
  engine = null;
  GC.Collect();
  GC.WaitForPendingFinalizers();
  GC.Collect();
   
  FREngine.FREngine.DeinitializeEngine();
  ```
</Accordion>

## Collecting garbage

All  objects in the .NET Core wrapper are derived from the IDisposable interface, which is responsible for releasing the resources allocated for objects. Implementing this interface ensures the collecting of the garbage automatically when an object is no longer needed. It is necessary to use the using statement for finishing with the objects, especially with heavy objects related to the document processing, synthesis, or export, such as [IFRDocument](/fine-reader/engine/api-reference/document-related-objects/frdocument), [IFRPages](/fine-reader/engine/api-reference/document-related-objects/frpages), [PDFExportParams](/fine-reader/engine/api-reference/parameter-objects/export-parameters/pdfexportparams), etc. (see the example below):

<Accordion title="С# code">
  ```csharp theme={null}
  using (FREngine.FRDocument document = engineLoader.Engine.CreateFRDocument()) 
  {
     try 
     {
       // Add image file to a document
       Console.WriteLine("Loading image...");
       document.AddImageFile(imagePath, null, null);
       ...
       // Save results to PDF using 'balanced' scenario
       using (FREngine.PDFExportParams pdfParams = engineLoader.Engine.CreatePDFExportParams()) 
       {
         pdfParams.Scenario = FREngine.PDFExportScenarioEnum.PES_Balanced;
         document.Export(Path.Combine(FreConfig.GetSamplesFolder(), @"SampleImages\Demo.pdf"),
         FREngine.FileExportFormatEnum.FEF_PDF, pdfParams);
       }
     }
  }
  ```
</Accordion>

In case you prefer not to use the using statement, explicitly call the Dispose method.

Samples

See the [Hello](/fine-reader/engine/guided-tour/samples#hello) code sample illustrating ABBYY FineReader Engine functioning in .NET Core.
