1

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?

sorrell
  • 1,801
  • 1
  • 16
  • 27

1 Answers1

1

Any 3rd party add-in may not expose any method at all other than those required to implement the add-in interface (OnConnection, etc.). Its methods can be internal (not public) or even can be obfuscated.

If it is your add-in, a better approach would be that the add-in provides commands to perform actions, and given your external DTE instance, you can call DTE.ExecuteCommand("MyAddIn.MyCommand").

Carlos Quintero
  • 4,300
  • 1
  • 11
  • 18