From 3b92ae2557c02073e45fcd5dc93c13b82cafb631 Mon Sep 17 00:00:00 2001 From: parnic Date: Tue, 14 May 2019 22:22:06 -0500 Subject: [PATCH] Fixed opening non-project files When files that weren't part of a project (added directly to a solution or open as a raw file outside the solution) were selected in the file list, a Not Implemented exception window was thrown up and VS would crash if the file was selected a second time. This catches the exception and attempts to open the file by path instead of by file reference. Fixes #6 --- ListFiles.xaml.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ListFiles.xaml.cs b/ListFiles.xaml.cs index ba5b991..4d76796 100644 --- a/ListFiles.xaml.cs +++ b/ListFiles.xaml.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; @@ -126,8 +127,16 @@ private void OpenSelectedFiles(bool bInSolutionExplorer) { if (!bInSolutionExplorer) { - var w = (item as ProjectItemWrapper).ProjItem.Open(); - w.Visible = true; + try + { + var w = (item as ProjectItemWrapper).ProjItem.Open("{7651A703-06E5-11D1-8EBD-00A0C90F26EA}"); + w.Visible = true; + } + catch (Exception) + { + var w = OpenFileInSolutionPackage.GetActiveIDE().ItemOperations.OpenFile((item as ProjectItemWrapper).Path); + w.Visible = true; + } } else {