Show / Hide Table of Contents

Using the OnLoad callback function

Add-Ins use the OnLoad() function that allows them to execute some code whenever the Add-In's .dll is loaded into RobotStudio.

Note

You can easily try out this example using the RobotStudio Empty Add-in template from Visual Studio.

Overriding OnLoad

  1. Create a C# class that inherits from the HostedAddInBase class:

    public class Class1 : HostedAddInBase 
    {
        // The Add-In's contents will go here
    }
    
  2. Write an overriding method for the OnLoad() method. Use the following code snippet to display a message whenever the Add-In is loaded.

    public class Class1 : HostedAddInBase 
    {
        public override void OnLoad() 
        {
            // This code will be executed when the assembly is loaded.
            Logger.AddMessage(new LogMessage("Hello: The Add-In has just been loaded!"));
            base.OnLoad();
        }
    }
    

The complete code for this example is:

using System;
using System.Collections.Generic;
using System.Text;

using ABB.Robotics.Math;
using ABB.Robotics.RobotStudio;
using ABB.Robotics.RobotStudio.Environment;
using ABB.Robotics.RobotStudio.Stations;

namespace Powerpac
{
    public class Class1 : HostedAddInBase
    {
        public override void OnLoad()
        {
            // This code will be executed when the assembly is loaded. 
            Logger.AddMessage(new LogMessage("Hello: The Add-In has just been loaded!"));
            base.OnLoad();
        }
    }
}

See Also

  • Save and Close Station callbacks
  • Managing Options
  • Activate/Deactivate callbacks
  • Unload Callback
  • Creating a RobotStudio Add-In
  • Creating an Add-In File
In this article
Back to top Copyright © 2025 ABB