[gme-users] Invoking a plug-in from an interpreter

Cinthya Lopez Cinthya_K_Lopez at raytheon.com
Wed Oct 17 15:11:43 CDT 2018


Hi Kevin,

I am not sure why I didn’t try to just create a new instance and call its methods. I think I was trying to follow a similar approach from how to grab instances of add-ons from the project, but that doesn’t seem to be necessary with plug-ins.

I was able to accomplish what I needed after your suggestion.

Thanks!
Cinthya

From: gme-users [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf Of Kevin Smyth
Sent: Wednesday, October 17, 2018 2:13 PM
To: A list for GME users to share thoughts and discuss bugs and fixes. <gme-users at list.isis.vanderbilt.edu>
Subject: [External] Re: [gme-users] Invoking a plug-in from an interpreter

Hi Cinthya,

I'm not sure what you're trying to accomplish here. Since you wrote the plug-in, couldn't you just create it directly with new and call methods?


At any rate, that HRESULT is E_MGA_ALREADY_IN_TRANSACTION, which means your plug-in is calling MgaProject.BeginTransaction, or your plug-in doesn't implement IMgaComponentEx and MgaLauncher calls BeginTransaction for it. The fix is to be sure you're implementing IMgaComponentEx and do not open (or close) a transaction if project.ProjectStatus & 8 == 8.

Kevin

On Wed, Oct 17, 2018 at 1:43 PM Cinthya Lopez <Cinthya_K_Lopez at raytheon.com<mailto:Cinthya_K_Lopez at raytheon.com>> wrote:
Hi All,

I am currently trying to invoke a plug-in from an interpreter. Does anyone have any experience on the best way to accomplish this?

I am writing both my interpreter and plug-in in C#. I currently have the following function in my interpreter.

        private void RunPlugIn(string filePath, MgaProject project)
        {
            MgaRegistrar mgaRegistrar = new MgaRegistrar();
            object obj = mgaRegistrar.get_AssociatedComponents(project.RootMeta.Name<http://project.RootMeta.Name>, componenttype_enum.COMPONENTTYPE_PLUGIN, regaccessmode_enum.REGACCESS_BOTH);
            Array plugins = (Array)obj;

            foreach (var pluginName in plugins)
            {
                if ((string)pluginName == "MGA.Interpreter.TestPlugIn")
                {
                    MgaLauncher mgaLauncher = new MgaLauncher();
                    if (mgaLauncher != null)
                    {
                        MgaFCO currentobj = null;
                        MgaFCOs selectedobjs = null;
                        mgaLauncher.RunComponent((string)pluginName, project, currentobj, selectedobjs, (int)ComponentStartMode.GME_EMBEDDED_START);
                        break;
                    }
                }
            }
        }

I can see the plug-in is found when calling get_AssociatedComponents () but I am getting an exception when calling mgaLauncher.RunComponent()

The exception reads: Exception from HRESULT: 0x87650036

It is my understanding that ComponentStartMode.GME_EMBEDDED_START is not really used by GME, but I am passing the startMode as such in hopes that it will help me identify when the plug-in is invoked by the interpreter. I am passing in currentobj and selectedobjs as NULL since I do not care about those (for now).

Any ideas what I may be doing wrong? Is this the recommended way to invoke a plug-in from an interpreter?

Thank you,
Cinthya
_______________________________________________
gme-users mailing list
gme-users at list.isis.vanderbilt.edu<mailto:gme-users at list.isis.vanderbilt.edu>
http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/gme-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20181017/f2e39dca/attachment.html>


More information about the gme-users mailing list