Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ApplicationEvents won't trigger

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
396 Views, 4 Replies

ApplicationEvents won't trigger

I'm having a general problem with the ApplicationEvents. They wont fire as they should...but sometimes they do!!

It's sort of like a 50/50 chance that they are working

 

Currenty I'm hooking up the OnQuit, OnOpenDocument and the OnSaveDocument events using the following code:

 

_application.ApplicationEvents.OnQuit += ApplicationEvents_OnQuit;

 void ApplicationEvents_OnQuit(EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
        {
            switch (BeforeOrAfter)
            {
                case EventTimingEnum.kBefore:
                    SaveSettingsToXml(_addinSettingsFilename);
                    HandlingCode = HandlingCodeEnum.kEventNotHandled;
                    break;
                default:
                    HandlingCode = HandlingCodeEnum.kEventNotHandled;
                    break;
            }
        }

 This model is applicable to all the events i mentioned, and is pretty straight forward. Tried running in Debug/Release which rules out any VisualStudio debugging problems, and right now I'm sort of out of ideas?! Anyone else having similar problems? 

 

Previous versions of this addin seems to be working ok using VB.Net - could there some sort of problem related to c#?

4 REPLIES 4
Message 2 of 5
rjay75
in reply to: Anonymous

I ran into this same issue. You need to use an event sink. So it would be

 

_application.ApplicationEvents.OnQuit = new ApplicationEventsSink_OnQuitEventHandler(ApplicationEvents_OnQuit);

 For some reason don't see a mention of them in the more recent apis but it's in the 2011 version. I know if I don't use them with C# event's don't seem to work correctly. 

Message 3 of 5
Anonymous
in reply to: rjay75

Great, thanks alot - will try this as soon as possible 😃

Message 4 of 5
Anonymous
in reply to: rjay75

Still having problems with this...any other idea? The OnCloseDocument-event seems to trigger now every time after using the ApplicationEventsSink. But this won't work!

 

_application.ApplicationEvents.OnQuit += new ApplicationEventsSink_OnQuitEventHandler(ApplicationEventsSink_OnQuitEventHandler);

 

private void ApplicationEventsSink_OnQuitEventHandler(EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
        {
            switch (BeforeOrAfter)
            {
                case EventTimingEnum.kBefore:
                    SaveSettingsToXml(_addinSettingsFilename);
                    HandlingCode = HandlingCodeEnum.kEventNotHandled;
                    break;
                default:
                    HandlingCode = HandlingCodeEnum.kEventNotHandled;
                    break;
            }
        }

 

Message 5 of 5
cadull_rb
in reply to: Anonymous

The following post may be useful, in particular keeping the ApplicationEvents object referenced.

 

http://forums.autodesk.com/t5/inventor-customization/events-in-the-api/m-p/3755999#M41929

 

Regards,

cadull

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report