External Assemblies

It is possible to use external assemblies in scripts and global modules. Both standard and compiled user assemblies can be used.

Adding external assemblies

You can add external assemblies on the Scripts tab of the Batch Type Properties dialog box or in Tools → Options…. All the classes and methods of the assemblies that you add are available to scripts and global modules.

Assemblies that you add to the properties of a batch type or a Document Definition are available only to that batch type or Document Definition.

To add an assembly:

  1. Open the Project Properties dialog box, click the Scripts tab, and then click the References .Net... button;
  2. In the dialog box that opens, click Add...;
  3. In the Add Assembly dialog box, select Attached file or Standard assembly name in the type field;
  4. Depending on the selected type, either specify the path to the file or the standard name.

Below you can find sample code of a user assembly that contains a namespace, a class, and a method of this class:

namespace TestNameSpace
{
public class Test
   {
   public void Show(string text)
      {
     // will show text message – static method Show(string text) from class System.Windows.Forms.MessageBox;
System.Windows.Forms.MessageBox.Show(text);
      }
   }
}

A script that uses class and methods of an external assembly should contain the following code:

TestNameSpace.Test test = new TestNameSpace.Test(); // creates an object of Test class
test.Show(“Hello world”); // calls void Show() method from Test class

Debugging external assemblies

When debugging external assemblies, both the assembly file and the *.pdb file with symbolic information are required. Only assemblies with loaded *.pdb files can be debugged. As *.pdb files are rather large, we recommend that you disable loading symbolic information in the working project.

Registry keys that control the loading of symbolic information:

You can use the following registry keys to specify whether *.pdb files should be loaded:

  • HKEY_CURRENT_USER\Software\ABBYY\ScanStationRS\5.0\Shell\Script [LoadSymbolsFromOriginalPath] - Specifies whether *.pdb files should be loaded from the same folder from which the assembly has been loaded (to load *.pdb files, set the value of the key to True)
  • HKEY_CURRENT_USER\Software\ABBYY\ScanStationRS\5.0\Shell\Script[PDBSearchLocations] = <path to the folder with PDB files> - Specifies the search paths where to look for *.pdb files (paths must be separated by semicolons; the search result is a *.pdb file with symbolic information, the name of the file is the same as the name of the assembly).

These keys are not created in the registry by default. If required, the Administrator may add these keys into the registry of the user's operating system.

For the changes in the registry to take effect, you need to restart the program.

To debug an assembly, you must connect to the managed code.

26.03.2024 13:49:49

Please leave your feedback about this article

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.