Click or drag to resize
Auto-References (C#)

CUSTOMTOOLS script add-ins may require some referenced assemblies (.dll files) in order to have wider range of functionality available. You can always select the dll assembly references by using the Referenced Assemblies options in script add-in management available in the CUSTOMTOOLS Administration Tool, but you can also determine the referenced dll assemblies in the beginning of your script's source code.

This topic shows how you can setup the automatic dll references in your Visual C# script code.

Automatic DLL Assembly References (C#)

As described above, selecting the dll assembly references could be done manually, but you can also setup the dll assembly references automatically in your script add-in's source code.

Syntax

Use the following syntax to add the automatic dll assembly references. Please note that the automatic dll assembly references have to be defined on the very first lines of your script's source code.

C#
// @auto-reference {<DllFilePath>\<DllFileName.dll>}

Attributes

Paths of the script add-in's automatic assembly references could be defined manually or, you can use the following pre-defined attributes to setup the dll file path automatically.

Attribute

Description

[CT_INSTALL_PATH]

Installation path of the CUSTOMTOOLS products. By default the [CT_INSTALL_PATH] attribute points to the C:\Program Files\ATR Soft\CUSTOMTOOLS 2018\

[ASSEMBLY_PATH]

The [ASSEMBLY_PATH] attribute points to the path where the referenced file is located in. This attribute should be used in case when the referenced assembly is located in a path that is not the add-in's target path but, the referenced file is required by the add-in's functionality. The [ASSEMBLY_PATH] could be used properly only with the reference assemblies that are uploaded to the script add-in as the script's Additional files.

Example

The following example code shows an example about how you can add the automatic dll assembly references in your script's source code.

In the example, several auto-references has [CT_INSTALL_PATH] defined as the DLL file path. The [CT_INSTALL_PATH] is a pre-defined attribute which means the installation path of the CUSTOMTOOLS version the script add-in is being used with. For example in case that the script add-in is used with the CUSTOMTOOLS 2018 version, the [CT_INSTALL_PATH] attribute is considered as the installation folder path where the CUSTOMTOOLS 2018 is installed in. Default installation path of the CUSTOMTOOLS 2018 is C:\Program Files\ATR Soft Oy\CUSTOMTOOLS 2018\.

C#
// @auto-reference {[CT_INSTALL_PATH]\Interop.CTEngineLib.dll}
// @auto-reference {[CT_INSTALL_PATH]\CTInterface.dll}
// @auto-reference {C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Drawing.dll}
// @auto-reference {C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.XML.dll}
// @auto-reference {C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.dll}

using System;
using System.Windows.Forms;
using System.Drawing;
using ATR.CT.CTInterface;
using CTEngineLib;

namespace MyNamespace
{
  public class MyClass
  {
    public MyClass(CTInterface oCTIFace)
    {
      MessageBox.Show("My script just got loaded!");
    }
  }
}
See Also