Skip to content

Commit 43e1c50

Browse files
authored
Merge pull request #5305 from MDoerner/SymtomaticFixForOpenModules
Log and swallow COM exceptions in SelectionProvider.OpenModules
2 parents f21dc85 + b271f92 commit 43e1c50

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Rubberduck.VBEEditor/Utility/SelectionService.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Runtime.InteropServices;
34
using NLog;
45
using Rubberduck.VBEditor.ComManagement;
56
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
@@ -42,7 +43,19 @@ public ICollection<QualifiedModuleName> OpenModules()
4243
{
4344
using (openCodePane)
4445
{
45-
openModules.Add(openCodePane.QualifiedModuleName);
46+
47+
try
48+
{
49+
var qmn = openCodePane.QualifiedModuleName;
50+
openModules.Add(qmn);
51+
}
52+
catch (COMException ex)
53+
{
54+
//For some reason, we sometimes get a COM Exception for 'invalid callee' here. So, we swallow it to avoid rendering rewrites unusable in that case.
55+
//See issue #5242 at https://github.com/rubberduck-vba/Rubberduck/issues/5242
56+
//TODO: Find the root cause of the sporadic exception and deal with it.
57+
_logger.Warn(ex, "Encountered an exception while getting the qualified module name of all open code panes. The current code pane will be skipped.");
58+
}
4659
}
4760
}
4861
}

0 commit comments

Comments
 (0)