question

JamesBendler-0529 avatar image
0 Votes"
JamesBendler-0529 asked Hrvoje-9896 commented

EnvDTE.ActiveDocument in VSIX Project

I'm writing a VSIX project in Visual Studio 2022 Preview.

If I try to execute this code, it fails with
System.MissingMethodException: 'Method not found: 'EnvDTE.Document EnvDTE._DTE.get_ActiveDocument()'.'

Code:

 ThreadHelper.ThrowIfNotOnUIThread();
 DTE dte = (DTE)MyPackage.GetGlobalService(typeof(DTE));
 string name = dte.ActiveDocument.Name;
vs-extensions
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @JamesBendler-0529
You can refer to this thread.


0 Votes 0 ·
  1. Remove all references to envdte and shell interop.

  2. Open NuGet and add the following packages: Microsoft.VisualStudio.SDK and Microsoft.VSSDK.BuildTools

  3. Double click source.extension.vsixmanifest inside your VSIX project, select Metadata tab

  4. Once there increase the version number of your extension

  5. Build the project

  6. Find yourapp.vsix inside bin folder and install it

Troubleshooting when uninstalling:
If you remove your VSIX using Extensions menu in VS, you'll need to close VS in order to let uninstall to happen.
Sometimes it doesn't uninstall completely, so make sure to open the log after the uninstall procedure ends.
In the log, get the path where the extension was installed. Open it in the file explorer and remove the folder entirely. Now the uninstall is complete and you can install new version of the extension.






0 Votes 0 ·

0 Answers