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

StackOverflow https://stackoverflow.com/questions/18580239

  •  27-06-2022
  •  | 
  •  

Domanda

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:

È stato utile?

Soluzione 2

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; }
    }

}

Altri suggerimenti

The problem is a result of one of your referenced dlls referencing another dll(for example as the return type from a method or property.) It is a flaw of the CLR. You can get around it by referencing the needed dll (in this case, Microsoft.VisualStudio.Shell.Interop.10). That solved it for me.

Read more here: http://blogs.msdn.com/b/vbteam/archive/2010/06/11/troubleshooting-errors-when-embedding-type-information-doug-rothaus.aspx

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top