I am making an addin in C#. It works fine, but it will not unload properly. When I try to shut down
Inventor, the process continues and can only be killed through the Task Manager.
The problem comes when I am adding commands. If the last line (marked ==>>) in the following code is
removed Inventor closes fine.
Any suggestions and guesses are welcome!
Poul Skadborg
Minimal C# addin code follows:
---------------------------------
using System.Runtime.InteropServices;
using Inventor;
namespace BilwincoCad
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("BilwincoCad.AddInServer")]
[GuidAttribute("FB0EC9AF-83F2-4879-B85C-A144D88E22C5")]
public class BilwincoAddIn : ApplicationAddInServer
{
private Inventor.Application invApp;
private ButtonDefinitionHandler btnHandler1;
public void ExecuteCommand(int CommandID) {}
public object Automation{ get {return null;}}
public void Deactivate()
{
Marshal.ReleaseComObject(btnHandler1);
Marshal.ReleaseComObject(invApp);
btnHandler1=null;
invApp=null;
}
public void Activate(ApplicationAddInSite AddInSiteObject,
bool FirstTime)
{
invApp=AddInSiteObject.Application;
btnHandler1=AddInSiteObject.CreateButtonDefinitionHandler(
"BilwincoMenuBar",
CommandTypesEnum.kShapeEditCmdType,
"btn1", "btn1","btn1",null,null);
CommandBarBase commandBar;
==>> commandBar=
invApp.EnvironmentBaseCollection.CommandBarBaseCollection["AMxAssemblyPanelCmdBar"];
}
}