4

I´m developing a visual studio extension, but unfortally I can´t check the project kind , please look de follow code:

 if (project.Kind == EnvDTE80.ProjectKinds.vsProjectKindSolutionFolder)
            {
                list.AddRange(GetSolutionFolderProjects(project));
            }
            else
            {
                list.Add(project);
            }

enter image description here

Igor Monteiro
  • 933
  • 1
  • 11
  • 29
  • 1
    The message is accurate, there is no "applicable interface" for this class. No big deal, select the EnvDTE80 reference in your project's References node and set its "Embed Interop Types" to False. You don't have to deploy it, any machine on which your code could work has this assembly in the GAC. – Hans Passant Jun 28 '18 at 15:55
  • My reference is laready set to false... – Igor Monteiro Jun 28 '18 at 16:49
  • 1
    @Will I don't think your first downvote is fair. The question includes the code with the issue (granted the image with the exception also contains the code) – user1007074 Dec 06 '18 at 09:44

2 Answers2

5

The common advice found online is to set "Embed Interop Types" to false for the EnvDTE80 reference to false. This however, doesn't work for me. I'm not sure whether this is new for VS 2017.

I found this MSDN page which helped me: https://blogs.msdn.microsoft.com/mshneer/2009/12/07/vs-2010-compiler-error-interop-type-xxx-cannot-be-embedded-use-the-applicable-interface-instead/

Basically,

  1. find the definition of ProjectKinds (which you can do by right clicking and choosing "Go to Definition")
  2. make a copy of ProjectKinds with a different name (ie. EnvDteProjectKinds) in your project
  3. Use EnvDteProjectKinds in your project where you would have used ProjectKinds
Robert Gowland
  • 7,677
  • 6
  • 40
  • 58
1

Visual Studio 2017 version 15.8 made it possible to use the PackageReference syntax to reference NuGet packages in Visual Studio Extensibility (VSIX) projects. This makes it much simpler to reason about NuGet packages and opens the door for having a complete meta package containing the entire VSSDK.

Installing below NuGet package will solve the EmbedInteropTypes Issue.

Install-Package Microsoft.VisualStudio.SDK.EmbedInteropTypes

Rahul
  • 2,431
  • 3
  • 35
  • 77