Specifics of Scripts Written in .Net Languages

This section describes some specifics of scripts written in .Net languages.

  • Object elements can be accessed using the Workspace and ExportBatch keywords.
  • .Net assemblies should be compiled using Microsoft .Net Framework 4.0 and above. You can specify a desired .Net Framework version in the properties of your Visual Studio project.
    Note. For details on how to use libraries that were created in .Net Framework 2.0, 3.0 и 3.5, see ABBYY FlexiCapture compatibility with different versions of the .NET Framework.
  • It is possible to add an external assembly that can be used in scripts and global modules. Both standard and compiled user assemblies can be used. All classes of the added assemblies will be available in scripts and global modules. See External Assemblies for details.
  • FlexiCapture objects do not support multithreading.
  • For debugging .Net scripts, the System.Diagnostics.Debugger.Break method is used.
  • When debugging .Net scripts, you also need a *.pdb file with debugging information. This file can be very large and we do not recommend storing it in the project together with your scripts. However, when debugging a .Net script, you must specify that the script should be compiled using certain debugging information.
    If you use Microsoft Visual Studio 2010, you can attach to the process where the .Net code is executed.
  • Scanning Station script objects are stored in the ScanStationInterop.dll assembly and belong to the ABBYY.ScanStation namespace. The ScanStationInterop.dll assembly is located in the root folder of the program.
  • All ABBYY Scan Station script objects are accessible under their own names from the ABBYY.ScanStation namespace. For example:
ABBYY.ScanStation.IWorkspaceItem activeBatch = Workspace.ActiveBatch;
    
  • The "Using" directives can be written in the beginning of the script body together with comments and empty strings. The same syntax as in the programming language is used (using for C#.Net, Import for JScript.Net and Imports for VisualBasic.Net). For example:
using System.Drawing;
    Image img = Image.FromFile( @"D:\2.png" );
    

Note. You can use the using directive in the script editor, provided that the keyword using occurs before the first line of the executable code. For example:

using System.IO;
    File.Create(@"C:\sample.txt");
    
  • In .Net scripts, functions from all global modules are called directly without using the name of the global module.
  • If you do not want to specify the value of an optional parameter of the function (for functions with optional parameters), you must pass System.Type.Missing instead.
  • To pause a script, use the Wait method of the IWorkspace interface. Using the standard Thread.Sleep method is insufficient.

1/14/2021 2:17:19 PM


Please leave your feedback about this article