Creating VS 2010 IDE instance throwing COM Exception

0

I have created a console app, which creates hidden instance of VS 2010 IDE & passes this instance as a parameter to an add-in which I use to call within the console app. ~concept of creating hidden instance, got from below link: Open a VS 2005 Solution File (.sln) into memory

But now I am getting below error while executing the console app.

Creating an instance of the COM component with CLSID {656D8328-93F5-41A7-A48C-B42858161F25} from the IClassFactory failed due to the following error: 80010001 Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)). My code:

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

            //To create instance of VS IDE
            t = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0", true);
            // Create a new instance of the IDE.
            obj = (EnvDTE80.DTE2)System.Activator.CreateInstance(t, true); //Getting error here//


            // Cast the instance to DTE2 and assign to variable dte.
            dte = (EnvDTE80.DTE2)obj;

            MessageFilter.Register();
            //Instantiate add-in class
            Connect addinObj = new Connect();
            addinObj.ValidateSolution(dte);
}

I am doing all this bcoz I don't want to show the devenv to user when my add-in is called.So tried this way.Tried googling, but din't get proper explanation/solution. This worked perfectly one day before, donno why its not working today...:(

~Deepthi

c#
visual-studio-2010
envdte
asked on Stack Overflow Nov 10, 2014 by Deepthi • edited May 23, 2017 by Community

1 Answer

0

This worked...!!

I have called the MessageFilter.Register(); line before creating the DTE instance, which worked. I guess the IOleMessageFilter handles these COM exceptions which are encountered due to threads.

~Deepthi

answered on Stack Overflow Nov 10, 2014 by Deepthi

User contributions licensed under CC BY-SA 3.0