hexagon logo

Events only firing one time within C# application

I have a C# application that initializes an instance of PCDLRN.dll and adds a bunch of ApplicationEvents to it. On the first execution of the program everything works fine but after that the events don't seem to be firing. As far as I can tell the PCDLRN.Application is not null, and the ActivePartProgram also isn't null. However, when I hit execute button in PC-DMIS a second time I don't see anything from the event handlers I attached to the ApplicationEvents object. Any suggestions would be greatly appreciated.
Parents
  • Just recently had this same occurrence when executing the application from within PC-DMIS customize menu. The application was created using NET 7.0. Then recreated the application using Framework 4.8 with no issues. I haven't had a chance to determine what the cause was yet.
  • So after a few more days of working on this issue I think I have more information about what is happening. To me it seems like I might be running into either a memory leak or race condition for the PCDLRN.INTEROP.dll file with my C# application and PC-DMIS itself. I have spent almost 30 hours trying to figure out what is going on. I have tried using threading, Synchronization Context, logging to a file, to the console, to a remote telemetry stream. The first execution of a program works perfectly, sometimes events fire on the second execution but not every event; somewhere in the middle of the program it just stops. I have tried slowing down the animation, waiting 5 minutes between program executions... I have no other ideas. I will try anything at this point. COM objects are so difficult to debug. Does anyone have any tips?
Reply
  • So after a few more days of working on this issue I think I have more information about what is happening. To me it seems like I might be running into either a memory leak or race condition for the PCDLRN.INTEROP.dll file with my C# application and PC-DMIS itself. I have spent almost 30 hours trying to figure out what is going on. I have tried using threading, Synchronization Context, logging to a file, to the console, to a remote telemetry stream. The first execution of a program works perfectly, sometimes events fire on the second execution but not every event; somewhere in the middle of the program it just stops. I have tried slowing down the animation, waiting 5 minutes between program executions... I have no other ideas. I will try anything at this point. COM objects are so difficult to debug. Does anyone have any tips?
Children
No Data