I don't know why, but this just started happening... my code loads a Template as an 'AddIn' grabs something from the AddIn and then deletes the AddIn from the list of Loaded AddIns. Here is the exception that is thrown. Let me know if an example is required...
**** Exception Text ****
System.Runtime.InteropServices.COMException (0x800A01A8): Exception from HRESULT: 0x800A01A8
at Microsoft.Vbe.Interop.VBProjectClass.get_HelpFile()
at Rubberduck.Parsing.VBA.RubberduckParserState.RemoveProject(String projectId) in C:UsershoschDocumentsVisual Studio 2015ProjectsRubberduckRubberduck.ParsingVBARubberduckParserState.cs:line 139
at Rubberduck.App.
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.
Ok more on this. I now know what changed in my project that results in this behavior. Below is the code that causes the crash. The thing that changed was how I clean up the AddIns, basically I started deleting them as soon as I got what I needed from them (they are just a template loaded as an AddIn). I commented out the delete code and now RD only crashes once... when the AddIn is loaded; unloading / deleting the AddIn does not seem to contribute to the crash. HTH
Function LoadAddin(ByVal sDot As String) As AddIn
Dim sPath As String
sPath = getPath("Templates") & Application.PathSeparator
Set PT_LoadAddin = Application.AddIns.add(sPath & sDot)
lbl_Exit:
Exit Function
End Function
So... reproduced in an otherwise empty word document... saved as .dotm
Module1 has this code:
Option Explicit
Private addinName As String
Sub LoadWordAddin()
addinName = "C:\WordTesting\Addin.dotm"
Word.AddIns.Add addinName ' <-- RD crashes after executing this line
DoEvents
DoEvents
End Sub
My money is on the parser kicking in while the IDE is running code. Parser kicks in because loading the addin adds a project to the VBE, which we pick up and handle by telling the parser there's new stuff to parse. We need some kind of flag that will tell the parser "a reparse was requested but the IDE wasn't ready for it, proceed when you can" - perhaps until we figure out a way to tell when the IDE mode is switching from "design" to "running" and back, the best we could do would be to set module state to Pending and let the user trigger it.
I think the reason it's failing is due to COM refusing to read the properties of the VBProject object because it's busy doing its thing, and it can only do one thing at a time.
...reading the exception more closely it seems the problem happened when the addin was _removed_, so parsing while the code is running may not be the root cause, but code that can remove a project from the IDE while Rubberduck is busy parsing it _is_ a problem, solved by forbidding parsing while the VBE is executing code. So the problem remains whole: we need to somehow pick up changes in the IDE's state (design/debug/break), and cancel/restart parse tasks accordingly. Definitely tricky!
...also please skip the _loaded assemblies_ part when pasting exception info - only the stack trace and exception type is useful/relevant. Thanks!
This issue has now seen no activity since almost 18 months, except in a reference from a now-closed issue.
Closing as inactive
Most helpful comment
...also please skip the _loaded assemblies_ part when pasting exception info - only the stack trace and exception type is useful/relevant. Thanks!