Events Firing c# AddIn ST8

Creator
Creator

Hi everyone,

 

We have updated solidEdge from st3 to st8. Now our Addin (developed in c#) has some problems with firing some events.

 

Here is the code:

 

SolidEdgeFramework.Application Application _application;

 

private void subscribeSolidEdgeEvents()
{
ISEApplicationEvents_Event seAppEvents = (ISEApplicationEvents_Event)_application.ApplicationEvents;
seAppEvents.AfterActiveDocumentChange += this.AfterActiveDocumentChange;
seAppEvents.AfterDocumentOpen += this.AfterDocumentOpen;
}

 

private void AfterActiveDocumentChange(object doc)
{
// do something
}

 

private void AfterDocumentOpen(object theDocument)
{
// do something
}

 

I have also updated Interop.SolidEdge nuget to the latest version (108.8.0), but both events (AfterActiveDocumentChange and AfterDocumentOpen)
not firing anymore. Can You help me please?

 

Thanks in advance.

2 REPLIES

Re: Events Firing c# AddIn ST8

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Your ISEApplicationEvents_Event seAppEvents are getting disposed because they are a local variable to the subscribeSolidEdgeEvents() method. Your code no longer works in new versions of SE because the devs changed the way they handle garbage collection (they own the process and default app domain so they can do that).

 

The correct approach is to make ISEApplicationEvents_Event seAppEvents a class variable. That way it will live throughout the lifetime of the class.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Events Firing c# AddIn ST8

Creator
Creator

Thank you so much. Now it's work!