Skip to content

Commit a6e17ae

Browse files
authored
bugfix: ignore specific ActiveDocument exception (#7677)
* bugfix: ignore specific ActiveDocument exception When there's no active document. for example - "project properties" dialog, calling application.ActiveDocument will throw the following exception: "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))" * Sign off contributors.txt
1 parent 7f48d5b commit a6e17ae

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Commands/ItemCommandBase.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ public override void OnCommand(_DTE application, OutputWindowPane pane)
1414
{
1515
if (!RunForSelection)
1616
{
17-
var activeDocument = application.ActiveDocument;
17+
Document activeDocument = null;
18+
try
19+
{
20+
activeDocument = application.ActiveDocument;
21+
}
22+
catch (Exception)
23+
{
24+
// It can fail when there's no active document. for example - "project properties" dialog.
25+
}
1826

1927
if (activeDocument?.ProjectItem == null)
2028
{

0 commit comments

Comments
 (0)