AddAnyFile: Receiving "The 'AddAnyFilePackage' package did not load correctly." error in VS2022

Installed product versions

  • Visual Studio: 2022 Enterprise Preview 1
  • This extension: 3.5.159

Description

Receiving “The ‘AddAnyFilePackage’ package did not load correctly.” error in VS2022 when attempting to create a new file (Shift-F2).

Steps to recreate

  1. Type Shift-F2 to invoke the extension
  2. Receive the above error dialog.

Current behavior

Receiving the error dialog instead of receiving the dialog for creating the new file/folder.

Expected behavior

Receive the dialog for creating a new file/folder. Screenshot 2021-06-23 152531

Relevant ActivityLog entries

<entry> <record>2697</record> <time>2021/06/23 15:48:20.780</time> <type>Information</type> <source>VisualStudio</source> <description>Begin package load [AddAnyFilePackage]</description> <guid>{27DD9DEA-6DD2-403E-929D-3FF20D896C5E}</guid> </entry> <entry> <record>2698</record> <time>2021/06/23 15:48:20.790</time> <type>Error</type> <source>VisualStudio</source> <description>SetSite failed for package [AddAnyFilePackage]Source: &apos;AddAnyFile&apos; Description: Could not load file or assembly &apos;EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; or one of its dependencies. The system cannot find the file specified.&#x000D;&#x000A;System.IO.FileNotFoundException: Could not load file or assembly &apos;EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; or one of its dependencies. The system cannot find the file specified.&#x000D;&#x000A;File name: &apos;EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos;&#x000D;&#x000A; at MadsKristensen.AddAnyFile.AddAnyFilePackage.&lt;InitializeAsync&gt;d__4.MoveNext()&#x000D;&#x000A; at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine&amp; stateMachine)&#x000D;&#x000A; at MadsKristensen.AddAnyFile.AddAnyFilePackage.InitializeAsync(CancellationToken cancellationToken, IProgress1 progress) at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass20_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e) at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck) 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]. </description> <guid>{27DD9DEA-6DD2-403E-929D-3FF20D896C5E}</guid>


80070002 <errorinfo></errorinfo> </entry> <entry> <record>2699</record> <time>2021/06/23 15:48:20.791</time> <type>Error</type> <source>VisualStudio</source> <description>End package load [AddAnyFilePackage]</description> <guid>{27DD9DEA-6DD2-403E-929D-3FF20D896C5E}</guid>
80070002 <errorinfo></errorinfo> </entry>`

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 18 (2 by maintainers)

Most upvoted comments

This is fixed and you should use the new Add New File (64-bit) extension for VS 2022

So I’ve spent the last day or two looking at this and trying to figure out what the problem is and how to get my favourite extensions working in VS2022…

Error

The issue is somehow related to binding to envdte.dll when the package is loaded. Using the Fusion log viewer I’m able to see that the correct envdte.dll library is located in C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\PublicAssemblies:

*** Assembly Binder Log Entry  (25/08/2021 @ 12:19:44) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/Microsoft Visual Studio/2022/Preview/common7/ide/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = devenv.exe
Calling assembly : AddAnyFile, Version=3.5.159.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\Howard\AppData\Local\Microsoft\VisualStudio\17.0_c575ab9e\devenv.exe.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/PublicAssemblies/EnvDTE.dll.
LOG: Assembly download was successful. Attempting setup of file: C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\PublicAssemblies\EnvDTE.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: envdte, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
WRN: Comparing the assembly name resulted in mismatch of Processor Architecture: Ref Legacy, Def MSIL.
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
LOG: All probing URLs attempted and failed.

The failure appears to be a mismatch on CPU architecture:

WRN: Comparing the assembly name resulted in mismatch of Processor Architecture: Ref Legacy, Def MSIL.
ERR: The assembly reference did not match the assembly definition found.

Since AddNewFile is compiled as any CPU, and the envdte.dll also appears to be MSIL I’m not sure why this is.

Fork

So I’ve forked the repo to https://github.com/conficient/AddAnyFile and tried out a few things. I tried just upgrading the VSSDK Build tools to preview 3 but that didn’t have any effect. I then went VS2022-only and updated the SDK to 17.0.0-previews-3. This breaks backward compatibility with VS2019 so I modified the name in the manifest to 'Add New File VS2022` and changed the version to minimum 17.0 so it only works on VS2022.

I then uninstalled the marketplace AddNewFile and ran the .vsix installer for AddNewFile VS2022 directly. This version installs in VS2022 and it works.

You can download the working version from the Release page of my fork. I’m not pulling these changes to this repo as they break backward compatibility for VS2017/2019.

Problem persists in VS 2022 17.0.0 Preview 4.0. @conficient version on my machine is working.

Same problem Microsoft Visual Studio Community 2022 Preview (64-bit) Version 17.0.0 Preview 3.0