[gme-users] About Add On Written in C# Activation Problem in GME

Kevin Smyth kevin.m.smyth at gmail.com
Wed Jan 24 10:11:55 CST 2018


Hi Somesh,

When the addons are restarted because you modified the active addons in
Tools>Register Components, the current addon is removed when IMgaAddon has
the final release or Destroy() is called. I think this is the proper way to
do this for C# addons:

diff --git a/Test_Project.cs b/Test_Project.cs
index fe7ba8a..a40ab55 100644
--- a/Test_Project.cs
+++ b/Test_Project.cs
@@ -18,7 +18,7 @@ namespace Test_Project
     ProgId(ComponentConfig.progID),
     ClassInterface(ClassInterfaceType.AutoDual)]
     [ComVisible(true)]
-    public class GetParameterList_AddOnAddon : IMgaComponentEx,
IGMEVersionInfo, IMgaEventSink
+    public class GetParameterList_AddOnAddon : IMgaComponentEx,
IGMEVersionInfo, IMgaEventSink, IDisposable
     {

         private MgaAddOn addon;
@@ -269,6 +269,12 @@ namespace Test_Project
             Registrar.UnregisterComponentsInGMERegistry();
         }

+        public void Dispose()
+        {
+            addon.Destroy();
+            addon = null;
+        }
+
         #endregion
     }



I'll update the templates in GME's C# component wizard.

Kevin

On Wed, Jan 24, 2018 at 6:54 AM, Somesh Das <somesh_au at yahoo.com> wrote:

> H
> I wrote a C# addon for GME. It will work for an object event "created",
> and when an object is created in GME it will show a message "An object has
> been created". However, I have a problem with activation of the addon. If I
> activate this addon multiple times in GME, it works multiple times during
> the event occurs. For example, if the addon is reactivated in GME three
> times, then when an object is created in GME, the addon is working three
> times for the same event.
> I attached the code of the addon. Please have a look and let me know if I
> am doing any mistakes.
>
> Thanks & Regards
> Somesh Das
>
>
> _______________________________________________
> gme-users mailing list
> 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/20180124/226a0f09/attachment.html>


More information about the gme-users mailing list