Loading the ComScript Module
Copying the Amt ComScript Module files
When the Amt ComScript Module will be used on a machine which does not have an installed AMT Environment, it is necessary to copy the Amt ComScript Module library files to this machine.
To do this copy the contents of the folder <Your AMT Environment>\AmtTools\ComScript, from a server with an installed AMT Environment, to a folder on the machine the Amt ComScript Module will be used.
Visual Basic
Please be aware that the Amt ComScript Module has limited functionality in non .NET languages due to
restrictions of COM services. As such the module should only be used in non .NET languages to maintain legacy applications. |
Registering the Amt ComScript Module
Before the Amt ComScript Module can be used in a Visual Basic (Script) program it first has to be registered as a COM service in the Windows Operating System:
- Register the AMT ComScript module named 'ComScript.comhost.dll', using Regsvr32.exe. This
can be done by executing the following command in an elevated (Run as administrator) Command Prompt window:
regsvr32.exe <Path to ComScript Module>\ComScript.comhost.dll
The <Path name> must refer to the directory to where you have copied the concerned dll-files.
Regsvr32.exe can be found in the
C:\Windows\System32 folder.
Note that on a 64-bit version of the Windows operating system, there are two versions of the Regsv32.exe file:
- The 64-bit version is %systemroot%\System32\regsvr32.exe.
- The 32-bit version is %systemroot%\SysWoW64\regsvr32.exe.
Be sure to use the correct version of Regsvr32.exe depending on the application that will use the Amt ComScript
Module.
Unregistering the AMT ComScript Module
It is important when upgrading AMT to a new fix or patch to first unregister the old ComScript module with the
command
regsvr32.exe /u <Path to ComScript
directory>\ComScript.comhost.dll
and then register the new version after AMT was upgraded.
To unregister older .NET framework versions of the ComScript, the following command can be used: Regasm /unregister <Path to ComScript directory>\ComScript.dll |
Loading the Module
When starting the Visual Basic program the Amt ComScript Module has to be loaded into memory and an object of the basic ComScript class has to be created. The code to do this is:
Powershell
Add-Type -Path '<Path to ComScript Module>\ComScript.dll'
# Then create a ComScript Module object
$ComScr = New-Object Asysco.Amt.Scripting.ComScript
C# (.NET)
Refering to the ComScript dll
Open (Create) the project to use the ComScript Module in, in Visual Studio. Then right click the 'Dependencies' node of the project and click 'Add Reference'. Browse to the folder <Your Environment>\AmtTools\ComScript and add a reference to the ComScript.dll.
Adding reference to System.Data.SqlClient 4.8.5
A reference to System.Data.SqlClient v4.8.5 needs to be added when the following exception occurs:
'System.Data.SqlClient is not supported on this platform'. The SqlClient reference is used
by AMT internally. When the exception happens, .NET was not able to resolve the correct version. This is solved by
adding the project reference.
This reference can be added via the NuGet package manager by right clicking on the 'Dependencies' node of the
project, browsing to System.Data.SqlClient version 4.8.5 and installing it.
Alternatively it can be added directly to the project file by adding the following package reference:
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
The ComScript Module can then be used in the code of the project.
It is advised to add a 'using Asysco.Amt.Scripting;' directive to every code file the ComScript Module will be used. |