Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Thomas.Long
613 Views, 15 Replies

Custom Plug in uninstalling itself

I have a plug in that I've created to install an autosave feature as my group and myself seem to be having issues with crashes. It looks like it should work in its current rudimentary form, and it's appearing in the list of plug ins in Inventor. However, when I go in and double click to set it to the installed setting, once I close it the plug in automatically gets uninstalled (i.e. I'll go right back in and Inventor will say it is uninstalled in the plug in manager again. Can anybody tell me why this is happening?

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FluentScheduler;

namespace ClassLibrary2 { class Scheduler : Registry { private Autosave Autosave = new Autosave(); public void Initialize() { JobManager.Initialize(new Scheduler()); } public Scheduler() { Schedule(() => Autosave.Run()).ToRunEvery(5).Minutes(); } private void ListenForException() { JobManager.JobException += (info) => MessageBox.Show(info.Exception.ToString()); } } }
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Inventor;

namespace ClassLibrary2
{
    [Guid("140622f8-7de6-475e-babe-2161e61e0286")]
    public class StandardAddinServer : ApplicationAddInServer
    {
        private Autosave Autosave = new Autosave();
        private Scheduler Scheduler = new Scheduler();

        public dynamic Automation
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        #region ApplicationAddInServer Members
        //Called by Inventor when it loads the addin 
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firsttime)
        {
            Autosave.iApp = addInSiteObject.Application;
            Scheduler.Initialize();
        }


        //Releases objects on quitting and opens up garbage memory
        public void Deactivate()
        {
            Autosave.iApp = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        public void ExecuteCommand(int CommandID)
        {
            throw new NotImplementedException();
        }
        #endregion

    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Inventor;

namespace ClassLibrary2
{
    class Autosave
    {
        public Application iApp { get; set; }

        public void Run ()
        {
            foreach (Inventor.Document iDoc in iApp.Documents.VisibleDocuments)
            {
                iDoc.Save();
            }
        }
    }
}

 

Thank you,

Thomas Long