Specifics of scripts written in .Net languages
This section describes specifics of scripts written in .Net languages.
- Additional keywords are not used to access object members. For example, in rules written in .Net languages the context of the rule is passed as a parameter with the name "Context".
- .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.
- 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.
- Once the script is compiled, a compiled script body is stored in the same location where the script is defined. Thus .Net script can occupy more space than other scripts.
- All FlexiCapture objects are defined as COM-objects, so functioning of .Net scripts can be slowed down when addressing object fields frequently because of managed-unmanaged transitions.
- 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.
- FlexiCapture script objects are stored in the ControllerInterop.dll and ShellInterop.dll assemblies and belong to the ABBYY.FlexiCapture and ABBYY.FlexiCapture.ClientUI namespaces, accordingly. The assemblies are located in the root folder of the program.
- All ABBYY FlexiCapture script objects are accessible under their own names from the ABBYY.FlexiCapture and ABBYY.FlexiCapture.ClientUI namespaces. For example:
ABBYY.FlexiCapture.IDocument document = Batch.Documents[i];>
ABBYY.FlexiCapture.ClientUI.IToolbars toolbars = TaskWindow.MainWindow.Toolbars;
- 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:
Image img = Image.FromFile( @"D:\2.png" );
FCTools.ShowMessage( img.VerticalResolution.ToString(), false );
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:
- In .Net scripts, functions from all global modules are called directly without using the name of the global module.
Note: Classes defined in the Rule Global Script Module and in the Export Global Script Module must have different names. Otherwise, when creating an instance of class in the code of rule, an error will occur.
- 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.null or System.Type.Missing instead.
Note: For scripts, that are executed noninteractively (that is by FlexiEx.exe process instead of FlexiCapture.exe), the Debug button is not displayed for the FlexiEx.exe process in the "Checking for solution" window by default (for scripts, that contain a breakpoint). For the button to be displayed, click on the Action Center icon on your task bar and select Change Action Center settings → Problem reporting settings → Never check for solutions.