1

I'm trying to make some refactorings in order to change namespace of some classes, create projects, etc.. using EnvDTE CodeModel.

I have tried various methods I found on the web, but nothing seems to work.

I'm using .Net 5.

For example, in this page are using directly DTE.Solution but when I try it on my solution, Intellisense gives me an error.

var solution = DTE.Solution;

Error: An object reference is required for the non-static field, method or property '_DTE.Solution'.

Another example I have found here is the following:

var dteInstance = serviceProvider.GetService(typeof(EnvDTE.DTE));

If I do that, the serviceProvider returns null to me. So I can't work with DTE.

I just need some help in order to get an instance of DTE, and later I would test all methods and properties that it gives me. But, how can I get the instance of DTE? How can I work with that?

I'm using an MVC web application to test it.

I appreciate so much your help.

JorgeAM
  • 91
  • 2
  • 10
  • Where are you trying your code? It seems you use it in a normal .NET 5 application. You must create a VsPackage project (VSIX) to use EnvDte. See https://learn.microsoft.com/en-us/visualstudio/extensibility/creating-an-extension-with-a-vspackage?view=vs-2019 – Peter Macej Jan 28 '21 at 17:55

0 Answers0