locked
'IServiceProvider' does not contain a definition for 'GlobalProvider' and no extension method 'GlobalProvider' accepting a first argument of type 'IServiceProvider' RRS feed

  • Question

  • User-1161428219 posted

    I'm new to C#. Please help me with the following code

    using EnvDTE;

    DTE dte = (DTE)ServiceProvider.GlobalProvider.GetService(typeof(DTE));
    Project project = dte.ActiveDocument.ProjectItem.ContainingProject;

    But I get the error 'IServiceProvider' does not contain a definition for 'GlobalProvider' and no extension method 'GlobalProvider' accepting a first argument of type 'IServiceProvider'.

    I could not figure out the reason for this error. Please let me know the cause of the error.

    Tuesday, February 27, 2018 4:47 AM

All replies