IPWright83 / VSFileNav

Visual Studio extension for rapid finding of files within a solution
21 stars 8 forks source link

The extension doesn't work in VS2017 if some features aren't installed #20

Open Anton-V-K opened 6 years ago

Anton-V-K commented 6 years ago

I used to use the extension with VS2017 - it had been working fine a couple of releases ago. However after I installed the version 15.5.2 of Visual Studio Community 2017 (Microsoft Visual Studio 2017 version: 15.0.27130.2010) on the new PC, I'm not able to use VSFileNav any more. The error is:

The 'VSNavPackage' package did not load correctly. The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'E:\Users\Anton\AppData\Roaming\Microsoft\VisualStudio\15.0_91a35b65\ActivityLog.xml'. Restarting Visual Studio could help resolve this issue.

The errors in the XML-log are:

LegacySitePackage failed for package [VSNavPackage]Source: 'EnvDTE' Description: Неизвестное имя. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME)) System.Runtime.InteropServices.COMException (0x80020006): Неизвестное имя. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME)) at EnvDTE.Events.GetObject(String Name) at VSNav.EventManager.GetDTE() at VSNav.VSNavPackage.Initialize() at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp) SetSite failed for package VSNavPackage

Anton-V-K commented 6 years ago

I've taken a look into the code and found the fragment in \VSFileNav\VSNav\Code\Gathering\EventManager.cs:

this.cSharpProjectEvents = dte.Events.GetObject("CSharpProjectItemsEvents") as ProjectItemsEvents;
this.vbProjectEvents = dte.Events.GetObject("VBProjectItemsEvents") as ProjectItemsEvents;
this.webProjectEvents = dte.Events.GetObject("WebSiteItemsEvents") as ProjectItemsEvents;

My Visual Studio Community 2017 (15.5.6) doesn't have the feature for Web-development installed (I've installed only limited set of features), so I guess the problem may be related to this...

I've accidentally ran into the missing feature error when trying to open some specific project: install_missing_features-asp net_and_web_development

Here is the full list of installed products: visual_studio-about-crop

It looks like a problem in VS, which fires a critical error when requested features isn't installed... but I could have overlooked something.

mmcintyre123 commented 6 years ago

I installed the ASP.Net and Web Development Package and that fixed the problem for me.

Anton-V-K commented 6 years ago

Installing extra features is a good workaround. Though with a small free space (on some SSDs) it may present a challenge... And I'd expect the issue to be fixed other way (installing unusable features of VS2017 seems to be an overkill).

rotanov commented 6 years ago

Hello. I also experienced this issue. I have 110Gb ssd with a little space left, so, yep, it's challenging.

Anton-V-K commented 5 years ago

The problem still happens with VS2017 15.9.9 :(

The fix seems to be straightforward - it is enough to catch System.Runtime.InteropServices.COMException in GetDTE() (in \VSFileNav\VSNav\Code\Gathering\EventManager.cs):

try
{
    this.webProjectEvents = dte.Events.GetObject("WebSiteItemsEvents") as ProjectItemsEvents;
}
catch (System.Runtime.InteropServices.COMException)
{
}

I tested it in my VS2017 without installed ASP.NET, and the custom-built addon works fine :) Here is the binary with hotfix - VSNav-HotFix.vsix.zip Just a reminder: the command is Edit.QuickFindFile with global shortcut Ctrl + Alt + F.

PS: Since this addon seems to be abandoned, it makes sense to switch to native navigation with Ctrl+, or Ctrl+Shift+T(see also https://stackoverflow.com/a/44164379/536172).