Plug in does not appear in Context Menu for TargetType

Posts   
 
    
TopDog74
User
Posts: 40
Joined: 27-Apr-2012
# Posted on: 14-Dec-2016 13:09:15   

Hi,

I am trying to write a plug in which is targeted at My Derived Model. However, no matter what i do the PlugIn does not appear on the context menu.

Note that i am using LLBLGen v5

Could you advise if i am missing something important in my code:

(Note that i have added lots of TargetTypes here just to see if i could get the plug in showing up somewhere in the context menu. However it is only intended for use with My DerivedModel)



 public class DataMemberOrderingPlugIn : PluginBase
    {
        private const string _build = "1.0.0";
        private const string _version = "1.0.0";
        private Control _control;

        public override PluginDescription Describe()
        {
            PluginDescription toReturn = base.Describe();

            toReturn.Build = _build;
            toReturn.Description = "General plug-in to add ordering to Derived Model Data Members";
            toReturn.Id = new Guid("{9FF8F454-69B9-4E35-B158-96E13C1F3F40}");
            toReturn.Name = "Add Data Member Ordering Plug-in";
            toReturn.ShowProgressViewerDuringExecution = true;
            toReturn.TargetType = PluginTargetType.SPCall | PluginTargetType.Entity |
        PluginTargetType.Project | PluginTargetType.ValueType |
        PluginTargetType.TypedList | PluginTargetType.TypedView | PluginTargetType.DerivedModel;
            toReturn.TypeOfPlugin = PluginType.SingleAndMultiElementPlugin;
            toReturn.Vendor = "TopDog74";
            toReturn.Version = _version;
        
            return toReturn;
        }

        public override System.Windows.Forms.Control GetConfigurationControl()
        {
            _control = new DataMemberOrderingPlugInForm(this);
            return _control;
        }

        public override void Execute()
        {
            base.ProgressTaskStart("Processing Derived Models");
            base.ProgressSubtaskInit(this.Entities.Count);
            
            //get all the derived models
            foreach (var derivedModel in this.Entities)
            {
                base.ProgressSubtaskStart("Processing Class: " + derivedModel.Name);
                ProcessSingleEntity(derivedModel);
                base.LogLineToApplicationOutput("Added Data Member Ordering to class: " + derivedModel.Name, "Add Data Member Ordering PlugIn", true);
                base.ProgressSubtaskComplete();
            }

            base.ProgressTaskComplete();
        }


        private void ProcessSingleEntity(EntityDefinition derivedModel)
        {
            //not relevant to question
        }

    }


The code for the form is like this: (Note that i will probably remove this and make the plug in a DirectRun type, however i wanted to get a form working with it in case i need to go down this route for something in the future also)


public partial class DataMemberOrderingPlugInForm : Form, IPluginConfigurationControl
    {
        private DataMemberOrderingPlugIn _pluginInstance;

        public DataMemberOrderingPlugInForm(DataMemberOrderingPlugIn pluginInstance)
        {
            InitializeComponent();
            _pluginInstance = pluginInstance;
        }
        
        public event EventHandler DataIsInvalid;

        public event EventHandler DataIsValid;

        public Guid FormID
        {
            get
            {
                return new Guid("{9FF8F454-69B9-4E35-B158-96E13C1F3F40}");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public Guid PluginID
        {
            get
            {
                return _pluginInstance.Describe().Id;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        private void btnRunTool_Click(object sender, EventArgs e)
        {
            if (DataIsValid != null) DataIsValid(this, e);
        }
    }

I cant debug my Execute code until i figure out why it is not appearing on the context menu for it's target type(s).

On loading of the project the output window tells me that the Plugin does get successfully loaded. - "PluginStore::Successfully loaded plug-in 'Add Data Member Ordering Plug-in' from assembly file 'F:\PlugInPractice\Model\Template\AdditionalPlugins\LLBLGenPlugIns.dll'."

Thanks, Iain

TopDog74
User
Posts: 40
Joined: 27-Apr-2012
# Posted on: 14-Dec-2016 13:31:03   

Update to this:

If i put the plugin dll into the LLBLGen plugins folder it does show up in the context menu fine.

However, if i make an additional plugins folder in project preferences, and then add my plugin dll in there, it does not show up in the context menu, even though i can see that the plug in gets loaded successfully when the project is opened.

Any ideas?

Thanks, Iain

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-Dec-2016 14:07:12   

We'll look into it.

(edit) reproduced. If I move the plugins dll to a separate folder, define that folder as the additional plugin folder and restart the designer, they're loaded fine, but aren't added the menu.

Looking into it.

(edit). It's a timing issue. The additional plugins are loaded asynchronously, and the project explorer already has built its menu cache for the plugin menu items when that happens. Which is of course not OK. Fixing...

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-Dec-2016 14:58:35   

Fixed. Please download the v5.1.2 hotfix build (or 5.0.10 hotfix) to correct this issue.

Frans Bouma | Lead developer LLBLGen Pro