Knowledge Base

Article ID: 1291 | Category: Project Setup | Type: FAQ | Last Modified: 8/22/2013

.NET support


Does FlexiCapture support .Net languages?  Can I use methods from my .Net assemblies in FlexiCapture scripts?


One of the coolest features which FlexiCapture 10 has in comparison with FlexiCapture 9.0 is .NET support. This means:

1.       Possibility to use .NET languages in any kind of scripts (rules, export, and so on).
And there is no need to install Visual Studio.

2.       Advanced support of external modules.
It’s enough to attach your own assembly (dll) to an FC project and you can use it directly in scripts. That’s it. You no longer need to copy the module onto every machine and register it. Module update is performed by one click, so there are no troubles with updating on all target machines. Moreover, it’s possible to debug an assembly during FC processing (using Visual Studio). After attaching a module, FC takes care of its storing and transferring, i.e. during export of a project the module will be exported as well.     

Let’s take a look at how to create an external assembly and how to connect it to FC.

  1. When creating a VS project, you must select Class Library as the output type:
  2. To be able to use FC objects in your VS project, you must add ShellInterop.dll (for shell objects) or ControllerInterop.dll (for other FC objects) to project’s references. In the code, you must add using ABBYY.FlexiCapture;
    Access to the FC objects will appear.
    Classes and methods, that you want to use in FC scripts, must be public (see the example below)
  3. Once the code is written and the project is compiled, simply attach the output *.dll file to FC. This can be done in various places, depending in which script you want to use it.

    Places where you can attach assemblies:

        - In the document definition (.Net References tab of the Document Definition Properties dialog)– for export, rule, auto correction, custom action, recognition, and assembly scripts
        - In the batch type (.Net References tab of the Batch Type Properties dialog) – for routing scripts and event handlers
        - In the project (.Net References tab of the Project Properties dialog) – for routing scripts and event handlers related to unknown documents

    To attach an assembly press Add… button, select Attach file and specify the path to the *.dll file which you want to attach:
  4. Once the assembly attached, all your public classes and methods are available from the FC scripts (depending in which place this assembly was attached (to document definition, batch type or project)).

From release 4 of FlexiCapture 10 assemblies added in project properties are shared assemblies which are available to all batch types and Document Definitions of the given project. So if you need to use the same assembly for more than one batch type or Document Definition you should add this assembly in project properties. If a shared assembly must be updated, you need to update it in project properties only.
After an assembly was added to the project it will be added to newly created batch types automatically. To add a shared assembly to a Document Definition or an existing batch type you need to click Add... button on the .Net References batch type, then select Shared Assemblies  in the Add Assembly dialog box and, finally, select the assembly name in the reference list.   

You can also attach standard assemblies from the GAC if you use it in scripts within FC. It’s not necessary to attach standard assemblies which are used in external modules.

Assemblies can be updated by clicking the Update button in the same dialog box.

Sample assembly (code):

using System;
using System.Windows.Forms;

namespace SampleAssembly
    public class MyClass
        public void MyMethod()
            MessageBox.Show("Hello, World!", "Information",
                MessageBoxButtons.OK, MessageBoxIcon.Information);

How to call MyMethod() from a FlexiCapture script:

using SampleAssembly;

MyClass cl = new MyClass();
578 people think this is helpful.
Was this information helpful to you?