I have an addin that connects to excel and writes things to the excel file.
I am running into a problem where the addin is not releasing the excel COM objects. I know I am releasing everything correctly in my code. the only way I have been able to get the objects released is by closing microstation.
I put the same code into a stand alone app for connecting to an excel COM object and releasing it via code and it is released (so that verified I am releasing it). So does anyone know why MicroStation is holding onto this?
Any one ever ran into this or have any ideas to try.
this posts describes how to release COM objects, but again a stand alone app has no problem releasing the COM objects.
https://stackoverflow.com/questions/25134024/clean-up-excel-interop-objects-with-idisposable/25135685#25135685
John Drsek said:I am running into a problem where the addin is not releasing the excel COM objects
Can you reproduce the problem using VBA?
Regards, Jon Summers LA Solutions
um..its been a long time since I connected to excel from vba. it takes a lot. I have to loop the ROT to find the excel instance that contains the excel file that I want to connect to.
the application is done and would take a lot of work to move it all to vba and I would lose a ton of functionality and the app is integrated with PW.
So not to be rude but I would rather not spend the time figuring out the code in vba to see if it gets released in vba because even if it is I wouldn't switch to it. hope you don't take that the wrong way.
I am assuming it has something to do with MicroStation not letting the garbage collector release objects.
John Drsek said:the application is done and would take a lot of work to move it
I'm not suggesting that you rewrite your app in VBA. I'm prompting you to test a COM invocation using VBA to provide clues.
Since you're writing .NET, one way to work with Excel is to write a COM wrapper. Presumably, Microsoft created that technology to solve your sort of problem?
Yet another way is to dispense with Excel and use a component such as Spread for Windows. Here's an example used to display Item Type instance data...
upon further testing and pin-pointing. it was not my code for interacting with excel at all (as i was properly releasing everything).
i actually narrowed it down to the ProjectWise (PW) api call aaApi_OpenDocument(). Simply calling this one api and doing nothing else is what is locking excel. i put a new question in on the PW SDK community. just a guess that whatever the SDK is doing to open the file it is not releasing the COM object.
https://communities.bentley.com/products/programming/projectwise_programming/f/projectwise-programming---forum/189201/c-aaapi_opendocument-and-aaapi_checkoutdocument-not-releasing-object-to-excel
just a side note to everyone out there..and a small rant..
i have made about 8 apps now for MicroStation CONNECT and/or ProjectWise and i have not gotten through a single app without finding out the SDK is missing that functionally completely or the SDK call doesnt work or there are bugs all over the place. its getting ridiculous, especially to spend days on this problem just to find out its most likely a problem with the SDK.