EnvDTE.ActiveDocument in VSIX Project

James Bendler 1 Reputation point
2021-09-06T19:04:52.25+00:00

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;
Community Center Not monitored
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.