Disable plugin from loading


I’m making a plugin and if for example my date.now that i saved is older then the date that is set on the pc my plugin should not load or work so I want to disable my plugin when this happens.
I’ve been searching in PlugIns.PlugIn.GetLoadProtection but then I have to give a Guid for 1 command.
Is it possible to disable the whole plugin instead of having to disable all 30 commands?

  • Jordy

Hi Jordy,

By overriding Rhino.PlugIns.PlugIn.OnLoad, you can decide at runtime whether or not you want your plug-is to load (or not). For example:

/// <summary>
/// Is called when the plug-in is being loaded.
/// </summary>
/// <param name="errorMessage">
/// If a load error is returned and this string is set. This string is the 
/// error message that will be reported back to the user.
/// </param>
/// <returns>An appropriate load return code.
/// <para>The default implementation returns <see cref="LoadReturnCode.Success"/>.</para></returns>
protected override LoadReturnCode OnLoad(ref string errorMessage)
  if (IsEvaluationExpired())
    errorMessage = "Your evaluation period of MyPlugIn has expired.";
  return LoadReturnCode.ErrorShowDialog;

Does this help?

A bit.

I’m trying to do this in VB.net and it does not recognize rhino.plugins.plugin.onload

This is what I’m at now:

Protected Overridable Function loadreturncode(ByVal errorMessage As String) Handles Rhino.PlugIns.PlugIn.onload

too fast reply.

this is the code:

  Protected Overrides Function OnLoad(ByRef errorMessage As String) As Rhino.PlugIns.LoadReturnCode

            errorMessage = "Your evaluation period of MyPlugIn has expired."

            Return Rhino.PlugIns.LoadReturnCode.ErrorShowDialog

        End Function

thank you very much Dale