I've added a control definition named, say, "MyAddInCommand" in my add-in.
Then an iLogic rule in my assembly model has the following line of code which executes that internal command.
ThisApplication.CommandManager.ControlDefinitions.Item("MyAddInCommand").Execute2(true)
That's dead simple. Works like a charm when I run the rule.
But that awesome line of code has its hissy fit when the rule is triggered from the "Any User Parameter Change" event.
The notorious COM exception E_FAIL is raised. And this was the stack trace from .NET COM interop.
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.ControlDefinition.Execute2(Boolean Synchronous)
at ThisRule.Main() in rule: MY_RULE_v2, in document MyAssembly.iam:line 3
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
But it works with other triggers like "Before Save Socument".
Am I missing any formalities in the event handler method in my add-in, or even anything else?