Loading of Add-Ins
When RobotStudio is launched, it searches the directories %ProgramFiles(X86)%\Common Files\ABB\RobotStudio\Addins
and %ProgramFiles(X86)%\ABB\RobotStudio version\Bin\AddIns
folder for .rsaddin
files.
The common location can be hard-coded in installers since it does not change between RobotStudio versions.
You can decide to deploy the .rsaddin
file or the assembly as described in locations where RobotStudio searches for Add-Ins to locate and load them.
An assembly is loaded with the only requirement, public static void AddInMain()
.
The AddinMain
method is used as an entry point method by RobotStudio to load the add-ins.
There are no restrictions on what the AddinMain
method can do, but it should never perform any operations that take a long time to execute.
This is absolutely essential, since the calling thread is the main initialization for the entire RobotStudio application. Long delays stops the entire RobotStudio application from loading.
If you still must perform operations that takes a long time to execute, ensure that this is done in a separate thread or after the user explicitly requests to perform the operation.
Loading a PowerPac
A hosted PowerPac add-in is a .NET assembly with the following additional requirements.
- The assembly must have a file of type
.rsaddin
, which must be located in one of the locations where RobotStudio searches for them. See Deployment. - The assembly must be located in the same folder as the
.rsaddin
file, or in the folder specified in the.rsaddin
file. - The assembly must contain a public class deriving Hosted
Add .In Base - The assembly must override the methods On
Activate() and OnDeactivate() .
When RobotStudio is launched, it scans for .rsaddin
files and extracts information about the PowerPacs, such as icon and description.
A button for each PowerPac appears under the Add-Ins tab, but the assembly is not loaded until the PowerPac is activated.
Initialization can be done by overriding On
Note
You can add the user interface of an add-in either by using code in
AddinMain
method or by using Ribbon.xml . During startup, RobotStudio calls theAddinMain
method when it loads the add-in into memory. RobotStudio will never call theAddinMain
method again, so if you are not using Ribbon.xml , then ensure to initialize everything that is needed for the add-in to execute so that a user can access the functionality of the add-in.Add-ins that are loaded into the same application domain as
RobotStudio.exe
can crash the entire application. Hence one must be cautious while implementing such add-ins.
Delay loading
RobotStudio contains a large number of DLLs and other assets which requires long time to load into the memory when starting the application.
RobotStudio start-up time will further be affected if many add-ins are installed, especially if these add-ins execute time consuming code during their start-up.
Long delays stops the entire RobotStudio application from loading. To avoid this problem, when RobotStudio is launched, it scans for .rsaddin
files
and extracts information about the add-ins. A button for each add-in appears under the Add-Ins tab, but the assembly is not loaded until the add-in gets activated.
This concept of not loading an assembly until it is needed is referred to as delay loading.
Delay loading of an add-in can be avoided by using the Ribbon.