Net 7.0 mac-windows compatibility - OnLoad not called

in short:
I came across a strange behaviour using the build project (.rhp) from the windows site, on the mac side. looks like OnLoad is not called - and some validation is bypassed.

in detail:
the behaviour can be repeated by:

  • On the windows site: build a new Solution/Project based on the template for visual Studio 2022, use the sample command (add a line).
  • add code below to the Rhino.PlugIns.PlugIn class.
  • build the project with Configuration “Release”.
  • on the Windows site, the plugin is not loading - as expected.
  • On the mac site:
  • using the net7.0 .rhp Relase from the Windows site, create a .macrhi following this instruction and install the plugin on the mac site. The Plugin / command is running ! :face_with_symbols_on_mouth: :ogre: :zebra: :monkey_face:
  • looks like OnLoad is never called

i know that this is not the recommended way to build a cross-platform plugin but it looks like it allows some strange behaviour or even licence bypassing.

@dan or @dale thanks for some thoughts / help / insights.

 protected override LoadReturnCode OnLoad(ref String errorMessage)
 {
     errorMessage = "..loading..";
     LoadReturnCode baseLoading = base.OnLoad(ref errorMessage);
     if (baseLoading != LoadReturnCode.Success)
     {
         return baseLoading;
     }
     bool isValid = ValidateStuff();
     if (isValid)
     {
         RhinoApp.WriteLine("success loading " + this.Name);
         errorMessage = errorMessage + "success";
         return LoadReturnCode.Success;
     }
     RhinoApp.WriteLine("failed loading " + this.Name);
     errorMessage = errorMessage + this.Name + "..failed";
     return LoadReturnCode.ErrorShowDialog;
 }
 private bool ValidateStuff()
 {
     RhinoApp.WriteLine("Fake Fail");
     return false;
 }

@Tom_P - seems to work as expected (for me).

TestLoadMePlugin.zip (25.8 KB)

The .macrhi method is obsolete. Use the package manager.

– Dale

on the mac site with the .rhp build on the windows site ? (site or side ?)
i am afraid that this method might bypass a minimal licence validation i do for some customers.

Yup…

– Dale

LoadTestPlugin.zip (190.5 KB)

above the minimal solution that shows the strange behaviour using the net7.0 release rhp:
(at least on my computer…)

on windows: - it does not load - as expected ! LoadReturnCode.ErrorShowDialog

on mac: no feedback in the command history, but LoadTestCommand is working (it should not as OnLoad will / should return LoadReturnCode.ErrorShowDialog

(using the same .rhp file)

??

systemInfo_tom_p.txt (6.6 KB)

Hi @Tom_P,

If you return LoadReturnCode..ErrorNoDialog will the plug-in not load correctly?

– Dale

changed the return value from OnLoad

    //return LoadReturnCode.ErrorShowDialog;
    return LoadReturnCode.ErrorNoDialog;

the plugin should not load - but it does:

on the mac command history

Command: LoadTestCommand
Fake Fail
failed loading LoadTestPlugin
LoadTestPluginAddingALine
The LoadTestCommand command will add a line right now.
The LoadTestCommand command added one line to the document.

Hi @Tom_P,

Thanks, I’ve logged the issue.

In the mean time, you might just move the validation call to the beginning of your commands and return if validation is unsuccessful.

– Dale

1 Like

many thanks for your fast reaction.

is there a nicer pattern as workaround ?
can i derive from the command class ?
class ValidatedCommand:Command
and put the Validation logic in there ?
… but not sure if there is a suitable override…
and then
class MyTestCommandAddLine:ValidatedCommand

@Tom_P - I’m sure there are many clever methods. Attached is one.

TestLoadMe.zip (27.1 KB)

– Dale

1 Like

Dear Dale - many thanks.
hopefully there is a easy fix soon.
thanks for your support.
kind regards -tom