ubsicap / paratext_demo_plugins

Sample code to demonstrate how to create a Paratext plugin
2 stars 4 forks source link

Adding a default constructor causes "missing default constructor" error #16

Closed steve-pence closed 2 years ago

steve-pence commented 2 years ago

I tried to add a default (parameterless) constructor to my plugin class. No matter what functionality I added to the constructor. Paratext displays the following in a dialog on startup; "Plugin "ScriptureMapLabeler.PluginMenu" failed to load: Missing default constructor." I was able to reproduce this by adding an empty constructor to ParatextHelloWorldMenuPlugin.HelloWorldMenuPlugin.cs consisting of the following single line of code: HelloWorldMenuPlugin() { }

Please understand, I'm not complaining about the inability to add an EMPTY constructor. The problem is that no matter what code I put inside, e.g. I'd like to add a trace listener, I get the same issue. I'm attaching my modified version of the demo code.

HelloWorldMenuPlugin .cs.txt .

jwickberg commented 2 years ago

Hello Steve,

The problem with your Hello World example is that you have made the default constructor private (that is the default scope when you don't specify it). This then hides the compiler generated public constructor that Paratext uses to create an instance of the plugin.

If you make the constructor public, it should work.

John

On Fri, Sep 9, 2022 at 5:05 AM steve-pence @.***> wrote:

I tried to add a default (parameterless) constructor to my plugin class. No matter what functionality I added to the constructor. Paratext displays the following in a dialog on startup; "Plugin "ScriptureMapLabeler.PluginMenu" failed to load: Missing default constructor." I was able to reproduce this by adding an empty constructor to ParatextHelloWorldMenuPlugin.HelloWorldMenuPlugin.cs consisting of the following single line of code: HelloWorldMenuPlugin() { }

Please understand, I'm not complaining about the inability to add an EMPTY constructor. The problem is that no matter what code I put inside, e.g. I'd like to add a trace listener, I get the same issue. I'm attaching my modified version of the demo code.

HelloWorldMenuPlugin .cs.txt https://github.com/ubsicap/paratext_demo_plugins/files/9533981/HelloWorldMenuPlugin.cs.txt .

— Reply to this email directly, view it on GitHub https://github.com/ubsicap/paratext_demo_plugins/issues/16, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANSZJW6EVICYDGSSKY7GHLV5L4XJANCNFSM6AAAAAAQIPRVIA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

steve-pence commented 2 years ago

Ah... beginner mistake. Brand new to C# here. I should have known it was something like that.

Thanks for your prompt response and clear explanation.

Steve

Steve Pence Publishing Coordinator SIL Southern Africa Fish Hoek, Cape Town South Africa

skype steve.pence WhatsApp +27 83 304 6658 GMT/UTC +2

On Fri, Sep 9, 2022, 4:08 PM jwickberg @.***> wrote:

Hello Steve,

The problem with your Hello World example is that you have made the default constructor private (that is the default scope when you don't specify it). This then hides the compiler generated public constructor that Paratext uses to create an instance of the plugin.

If you make the constructor public, it should work.

John

On Fri, Sep 9, 2022 at 5:05 AM steve-pence @.***> wrote:

I tried to add a default (parameterless) constructor to my plugin class. No matter what functionality I added to the constructor. Paratext displays the following in a dialog on startup; "Plugin "ScriptureMapLabeler.PluginMenu" failed to load: Missing default constructor." I was able to reproduce this by adding an empty constructor to ParatextHelloWorldMenuPlugin.HelloWorldMenuPlugin.cs consisting of the following single line of code: HelloWorldMenuPlugin() { }

Please understand, I'm not complaining about the inability to add an EMPTY constructor. The problem is that no matter what code I put inside, e.g. I'd like to add a trace listener, I get the same issue. I'm attaching my modified version of the demo code.

HelloWorldMenuPlugin .cs.txt < https://github.com/ubsicap/paratext_demo_plugins/files/9533981/HelloWorldMenuPlugin.cs.txt

.

— Reply to this email directly, view it on GitHub https://github.com/ubsicap/paratext_demo_plugins/issues/16, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AANSZJW6EVICYDGSSKY7GHLV5L4XJANCNFSM6AAAAAAQIPRVIA

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/ubsicap/paratext_demo_plugins/issues/16#issuecomment-1242022496, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ4HZN6HPDE55R3MBPXTIETV5NAHBANCNFSM6AAAAAAQIPRVIA . You are receiving this because you authored the thread.Message ID: @.***>

steve-pence commented 2 years ago

Confirming that making the constructor public resolved the issue.