dimanche 13 septembre 2015

How to access a Visual Studio DTE Addin assembly

Here is what I'm trying to do:

  1. Create an executable that loads the Visual Studio DTE
  2. Access methods of an Addin that is loaded

Here is my code, as followed loosely from this blog.

[STAThread]
static void Main(string[] args)
{
    EnvDTE80.DTE2 dte;
    object obj = null;
    System.Type t = null;

    MessageFilter.Register();
    // Get the ProgID for DTE 10.0.
    t = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0", true);
    obj = System.Activator.CreateInstance(t, true);

    var addin = GetAddInByProgID(dte, "MyAddin");
    if (addin != null)
    {
        addin.Connected = true;
        var connectObj = addin.Object;
        var conObjType = connectObj.GetType();
        var methods = conObjType.GetMethods();  // mscorlib methods
        var asm = conObjType.Assembly;  //  is mscorlib
     }
     ...
}

The problem I'm running into is I can't get access to the Addin's assembly. It appears that conObjType's assembly is mscorlib - but I want access to Myaddin.dll. Any ideas?





Aucun commentaire:

Enregistrer un commentaire