I am having an issue with a OnSave Addin, that after working on a few drawings, it fails with the COM object that has been separated from its underlying RCW cannot be used. message. I can't see any reason that it should be loosing its reference to the Inventor.Application.
Has anyone else run into this issue with the on save events? The odd thing is that I used the program for a long time, without any issues, but now I can only work on maybe 6 or 7 drawings before it pops up.
Anyone have any good tips on how to actually debug where it is loosing the reference, and why?
Solved! Go to Solution.
Solved by KentKeller. Go to Solution.
Hi Kent,
OS version? Inventor version? Is it .NET AddIn?
By OnSave AddIn you mean a translator AddIn?
You could keep writing to a log file to see if it's having issues with a specific function call.
Cheers,
Hi Adam,
Thanks for the reply.
I am using Windows 7, and it is a .Net Addin. This is a simple addin to write a PDF file (using pdfcreator's api) anytime a save is done on a drawing.
I disabled a few other addins, and it seems like it might have fixed it, but since I made that change I really haven't been opening and saving multiple files in a row.
I am hoping to find time to do some testing to make sure the problem is gone, and then turn back on the addins one at a time to see which one is somehow conflicting.
Finally got back to this. I have pretty much every other addin disabled and it is still happening, so it idoesn't appear to be caused from other addins. The error tells me which line it fails on, but I believe it probably fails before that. I just don't see any reason it should
So what code line does it fail on?
Can you consistently reproduce the error and does it always happen on the same code line?
Adam,
For some reason it is working fine this week. Last week I found that if while running it from the debugger, when it failed, if I unloaded the addin in Inventor, waited a while, and then reloaded it, I wouldn't get errors any more. Other than that I didn't change anything, but it is working fine now.
Before it was failing on the last line in the code below
Private Sub oApplicationEvents_OnSaveDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles oApplicationEvents.OnSaveDocument Try ' BEFORE If BeforeOrAfter = EventTimingEnum.kBefore Then ' IDW Zoom Extents If DocumentObject.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then