Skip to main content
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.
  • 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.
  • Scanning Station 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.
  • 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.