I'm trying to update my Diff All Files Visual Studio extension to support VS 2017. When debugging my extension it is complaining that it cannot find a required assembly:
System.Windows.Markup.XamlParseException occurred
HResult=0x80131501
Message=Could not load file or assembly 'QuickConverter, PublicKeyToken=9c892aa7bc2af2cf' or one of its dependencies. The system cannot find the file specified.
Source=PresentationFramework
StackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at VS_DiffAllFiles.Sections.DiffAllFilesSectionControl.InitializeComponent() in D:\dev\Git\VS.DiffAllFiles\VS.DiffAllFiles.VS2017\obj\Debug\DiffAllFilesSectionControl.xaml:line 1
at VS_DiffAllFiles.Sections.DiffAllFilesSectionControl..ctor(DiffAllFilesSectionBase parentSection) in D:\dev\Git\VS.DiffAllFiles\VS.DiffAllFiles\Sections\DiffAllFilesSectionControl.xaml.cs:line 18
at VS_DiffAllFiles.DiffAllFilesBaseClasses.DiffAllFilesSectionBase..ctor() in D:\dev\Git\VS.DiffAllFiles\VS.DiffAllFiles\DiffAllFilesBaseClasses\DiffAllFilesSectionBase.cs:line 82
at VS_DiffAllFiles.DiffAllFilesBaseClasses.TfsDiffAllFilesSectionBase..ctor()
at VS_DiffAllFiles.DiffAllFilesBaseClasses.SupportsIncludedAndExcludedChangesTfsSectionBase..ctor()
at VS_DiffAllFiles.Sections.PendingChangesSection..ctor() in D:\dev\Git\VS.DiffAllFiles\VS.DiffAllFiles\Sections\PendingChangesSection.cs:line 27
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'QuickConverter, PublicKeyToken=9c892aa7bc2af2cf' or one of its dependencies. The system cannot find the file specified.
I have confirmed that the file exists at C:\Users\Dan.Schroeder\AppData\Local\Microsoft\VisualStudio\15.0_b920d444Exp\Extensions\DansKingdom\Diff All Files for VS2017\1.0\QuickConverter.dll
and that it has the correct Name and PublicKey.
I have also captured the Fusion Logs (i.e. Assembly Binding Log Viewer) to capture the binding error, and it seems that VS is not looking for the dll file in the directory where it's located; rather than looking in the experimental extensions directory, it's looking in the actual VS 2017 directory. I captured this error, and another with the fully-qualified name that included the version, which is the correct version of the assembly:
*** Assembly Binder Log Entry (4/13/2017 @ 1:18:51 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = QuickConverter, PublicKeyToken=9c892aa7bc2af2cf
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: QuickConverter, PublicKeyToken=9c892aa7bc2af2cf | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = devenv.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Dan.Schroeder\AppData\Local\Microsoft\VisualStudio\15.0_b920d444Exp\devenv.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/QuickConverter/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PublicAssemblies/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PublicAssemblies/QuickConverter/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/QuickConverter/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/QuickConverter/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Platform/Debugger/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Platform/Debugger/QuickConverter/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/QuickConverter/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/DataCollectors/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/DataCollectors/QuickConverter/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/DataCollectors/x86/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/DataCollectors/x86/QuickConverter/QuickConverter.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/QuickConverter/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PublicAssemblies/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PublicAssemblies/QuickConverter/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/QuickConverter/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/QuickConverter/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Platform/Debugger/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Platform/Debugger/QuickConverter/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/QuickConverter/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/DataCollectors/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/DataCollectors/QuickConverter/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/DataCollectors/x86/QuickConverter.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/PrivateAssemblies/DataCollectors/x86/QuickConverter/QuickConverter.EXE.
LOG: All probing URLs attempted and failed.
Any thoughts as to why VS is not looking in the correct location to load that assembly? Or is there something else I'm missing?
I did not run into this issue when developing the extension for VS 2012, 2013, or 2015. I'm debugging the Visual Studio Extension by providing the rootsuffix Exp
command line argument, just like I did for previous Visual Studio versions.
If you want, you can download the source code and reproduce the issue for yourself (it's the AddVs2017Support
branch); just unload all projects except the VS.DiffAllFiles and VS.DiffAllFiles.VS2017 projects.
Any thoughts/suggestions are appreciated. Thanks.
As per the link that Hans Passant provided, I tried adding a .pkgdef file to my project and including it as an asset in my .vsixmanifest file, but the problem still remains. When I look in the C:\Users\Dan.Schroeder\AppData\Local\Microsoft\VisualStudio\15.0_b920d444Exp\devenv.exe.config
file I still do not see any reference to my assemblies, so it doesn't seem to be adding anything to that file as it should. Also, the fusion logs still report the exact same information as I provided above.
When I try to generate the .pkgdef file manually (since it should be done automatically as part of the build process), I get the following error. I'm not sure if this is to be expected or not when trying to generate it outside of Visual Studio (I was just using a regular command prompt).
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VSSDK\VisualStudioIntegration\Tools\Bin>CreatePkgDef.exe /out="C:\Temp\Def.pkgdef" "C:\Users\Dan.Schroeder\AppData\Local\Microsoft\VisualStudio\15.0_b920d444Exp\Extensions\DansKingdom\Diff All Files for VS2017\1.0\VS.DiffAllFiles.VS2017.dll"
Visual Studio (R) PkgDef Creation Utility.
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly: VS.DiffAllFiles.VS2017 1.0.0.0
Output file: C:\Temp\Def.pkgdef
CreatePkgDef : error : ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Microsoft.VisualStudio.Tools.CreatePkgDef.ProcessAssembly(String fileName, Hive hive, PkgDefContext context, Boolean register, RegistrationMode mode) in F:\dd\src\vssdk\VSIntegration\Tools\src\CreatePkgDef\CreatePkgDef.cs:line 261
at Microsoft.VisualStudio.Tools.CreatePkgDef.DoCreatePkgDef(InputArguments inputArguments) in F:\dd\src\vssdk\VSIntegration\Tools\src\CreatePkgDef\CreatePkgDef.cs:line 164
at Microsoft.VisualStudio.Tools.CreatePkgDef.Main(String[] arguments) in F:\dd\src\vssdk\VSIntegration\Tools\src\CreatePkgDef\CreatePkgDef.cs:line 85
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.
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.
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.
Again, these latest changes have been pushed to the source code on GitHub under the AddVs2017Support
branch for anyone who cares to take a look at the code to try and spot the problem.
I also tried Resetting The Visual Studio 2017 Experimental Instance, as well as installing the vsix on my regular (non-experimental) VS 2017 instance, but it still results in the same error about not being able to find the assembly.
If I manually copy the dll file to the C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE
directory then it is found and I no longer get the error. I'm just not sure why Visual Studio is not looking for it in my extensions directory, when the exact same file does indeed exist there.
You may try to add the following code in AssemblyInfo.cs of your VSIX project:
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\QuickConverter.dll")]
I tried and worked well with VS 2017 update 7.
I ran into a similar scenario and was getting the same error and fusion log results. What I ended up doing to get to the root of the issue was enable activity logging in the experimental instance while debugging. So in the debug settings on the VSIX project, change the startup arguments to "/rootsuffix Exp /log".
Debug the extension and repro the issue.
Then check the activity log file at: C:\Users\%username%\AppData\Roaming\Microsoft\VisualStudio\15.0_796eceb7Exp\ActivityLog.xml
In my particular instance, I was using a project template with a wizard extension. In the .vstemplate file for the project there is a magic string with the namespace & classname of the wizard implementation. I had renamed the class but didn't update the string in the template.
I never was able to determine the root cause of this issue. What I had done originally was create a new VS2017 VSIX project in Visual Studio and then include all of the files from my VS2015 VSIX project in it, and that's when I encountered this error.
What ended up working for me was to delete that VS2017 project, and instead just do a copy-paste of my existing VS2015 project and then rename the .csproj and other files to 2017 instead of 2015. I then opened that project in VS 2017 and let it do the upgrade migration, and then updated the vsixmanifest file to support VS 2017. Once that was done, then things worked as expected.
After some days of research, I was able to get it working for me with VS 2017. The general problem is indeed that Visual Studio is looking for the assemblies in the wrong places. There was no problem with the signing as I had previously suspected. My VSIX/Wizard assembly was included in VSIX, but after I installed it, it wasn't found by VS. And if you look into the C:\Users\Username\AppData\Local\Microsoft\VisualStudio\15.0_ff857330Exp\Extensions folder, the assembly is there. Seems that VS just isn't searching for it there.
The solution is therefore to set the "Install root" property.
The assemblies referenced in the manifest will then be copied on VSIX installation to the location C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies where they get easily found when using the installed templates. As far as I read, there is no way to change the default installation path in another way or do it without elevated permissions.
Hopefully this answer saves you days of research and trying.
User contributions licensed under CC BY-SA 3.0