Search code examples
vsxvisual-studio-2013

Microsoft.VisualStudio.Shell.Interop.ToolWindowPane Class gives error when compiling in Visual Studio 2013 preview


I'm building a Visual Studio package for Visual Studio 2013..This same package works perfectly for Vs 2012 and previous. This is the code of the class:

public class MyClassWindowPane : ToolWindowPane
    {
        public MyClassPanel MyClassPanelControl;
        public List<IVsDataExplorerConnection> Connections { get; set; }
        public string SelectedConnectionName { get; set; }

        public MyClassWindowPane()
            : base(null)
        {
            MyClassPanelControl = new MyClassPanel();
        }

        public void InitializeMyClassPanel()
        {
            MyClassPanelControl.LoadConnections(Connections, SelectedConnectionName);
        }

        override public IWin32Window Window
        {
            get { return (IWin32Window)MyClassPanelControl; }
        }

    }

The errors I'm getting are the following:

Cannot find the interop type that matches the embedded interop type 'Microsoft.VisualStudio.Shell.Interop.IVsWindowSearch'. Are you missing an assembly reference?

Cannot find the interop type that matches the embedded interop type 'Microsoft.VisualStudio.Shell.Interop.IVsUIElementPane'. Are you missing an assembly reference?

I'm including the following references

using Microsoft.VisualStudio.Shell;
using System.Windows.Forms;
using System.ComponentModel.Design;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.Win32;

which should be more than enough to compile..

Looks like the culprit is on the ToolWindowPane class, since if I remove it everything compiles without any error.

Does anybody knows why is this issue occurring?

Thanks in advance for any lead

I have already tried the solution mentioned here Interop type cannot be embedded with no luck:


Solution

  • I had to do some changes so here is the code that finally worked:

       using System.Windows.Forms;
       using System.Runtime.InteropServices;
       using Microsoft.VisualStudio.Shell;
       using Microsoft.VisualStudio.Data.Services;
       using System.Collections.Generic;
       using Microsoft.VisualStudio.Shell.Interop;
       using Microsoft.VisualStudio;
    
       namespace My.VisualStudio.Package
       {
        public class MyClassWindowPane : ToolWindowPane, IVsWindowFrameNotify2
        {
        public MyClassPanel MyClassPanelControl;
        public List<IVsDataExplorerConnection> Connections { get; set; }
        public string SelectedConnectionName { get; set; }
    
        public MyClassWindowPane()
            : base(null)
        {
            MyClassPanelControl = new MyClassPanel();
        }
    
        public void InitializeMyClassPanel()
        {
            MyClassPanelControl.LoadConnections(Connections, SelectedConnectionName);
        }
    
        override public IWin32Window Window
        {
            get { return (IWin32Window)MyClassPanelControl; }
        }
    
    }