VioletGiraffe / cppcheck-vs-addin

Visual Studio integration for cppcheck, an open-source static code analyzer for C++
MIT License
413 stars 86 forks source link

The add-in fails to load in VS 2015 #169

Closed VioletGiraffe closed 6 years ago

VioletGiraffe commented 7 years ago

Not sure what's going on. There's nothing on it in the Activity Log, and when I attempt to debug the add-in in VS 2015, the plugin is not even installed in the experimental instance, even though the debugging settings are correct. There are no related messages.

WhoWouldaThunk commented 7 years ago

I just reinstalled windows (was on 8.1, now on 10) and VS 2015, downloaded your addon, and had that issue too! Here's what I have in my activity log for it:

CreateInstance failed for package [CPPCheckPluginPackage]Source: 'mscorlib' Description: Could not load file or assembly 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

VioletGiraffe commented 7 years ago

So, the plugin currently depends on Shell 15.0 which is the VS 2017 version. For compatibility with VS 2015, Shell 14.0 reference should be added. But then I'm getting numerous errors of the following kind:

error CS0433: The type 'ToolWindowPane' exists in both 'Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

icnocop commented 6 years ago

I created pull request https://github.com/VioletGiraffe/cppcheck-vs-addin/pull/177 to resolve this issue.

The latest appveyor build is here: https://ci.appveyor.com/project/icnocop/cppcheck-vs-addin/build/1.3.5

Notice that there are separate vsix artifacts for Visual Studio 2015 and Visual Studio 2017 because of the different references to "Microsoft.VisualStudio.Shell".

Thank you.

VioletGiraffe commented 6 years ago

@icnocop Thanks! So, it's not possible to support both VS versions with the same VSIX file? Or is it just that none of us knows how to do it?

icnocop commented 6 years ago

VSIX files can support multiple versions of Visual Studio.

I think it would need to be configured in the vsixmanifest file if it's not already configured.

I personally don't have a lot of experience with vsixmanifest files.

The problem here is the dependency on EnvironmentColors and ThemeResourceKey which are defined in Microsoft.VisualStudio.PlatformUI and Microsoft.VisualStudio.Shell respectively, and those are different depending on the version of Visual Studio SDK that's installed.

I'm thinking we can try to either decouple that dependency, or maybe include those assemblies within the VSIX (if the license permits for example), then we may not need to build two versions of the VSIX.

icnocop commented 6 years ago

Here's a good reference: https://msdn.microsoft.com/en-us/magazine/mt493251.aspx

It seems that instead of referencing Microsoft.VisualStudio.Shell.14.0 and Microsoft.VisualStudio.Shell.15.0, we need to reference Microsoft.VisualStudio.Shell.11.0, but I haven't tested this yet.

https://stackoverflow.com/a/37880406/90287 indicates we can use the NuGet Package VSSDK.Shell.11.

I'll have to test it out. :)

icnocop commented 6 years ago

I tested CppcheckPlugin.vsix from https://ci.appveyor.com/project/VioletGiraffe/cppcheck-vs-addin/build/1.3.8/artifacts in Visual Studio 2015 Update 3 on Windows 10 64-bit and it works without issues. :)

ruizpauker commented 6 years ago

Hi, I'm facing this error with VS2015, is there any way to overcome it?

VioletGiraffe commented 6 years ago

Try the VSIX linked above.

ruizpauker commented 6 years ago

Yes, thanks I tried that one and it worked!

Anyway thou I'm wondering why it's not included as a Project Relase, the latest relase there is 1.3.4 while the one on the link provided is 1.3.8, shouldn't this be harmonized/synced?

VioletGiraffe commented 6 years ago

I remember how I thought it's time to update the release, but don't recall why I didn't go through with that after all. Perhaps, another important bug was discovered. But you're right, I should probably release the latest version and see what happens.

ruizpauker commented 6 years ago

If support is needed I'll be glad to help.

gordon-proctor commented 6 years ago

The artifact at https://ci.appveyor.com/project/VioletGiraffe/cppcheck-vs-addin/build/1.3.8/artifacts has been deleted as it was more than 6 months old. Can you generate a new one or include it in the Project Release?

VioletGiraffe commented 6 years ago

@gordon-proctor : try this one. CppcheckPlugin.zip

gordon-proctor commented 6 years ago

That worked, thank you.

VioletGiraffe commented 6 years ago

Should be fixed in the latest release now.