Create visual studio macro in console application
===

I will like to create visual studio macros in c#. What am I doing now is to create the macros in a class library then execute them from vba. the problem is that I cannot debug the macros because I cannot step into the dll from vba.

Anyways I will like to create the macro in a console application for debuging purpuses. Once I know it works I will just place it on the dll. 

Here is my code so far:


    class Program
    {        
        static void Main( string[] args )
        {            
            EnvDTE80.DTE2 MyDte;
            MyDte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject( "VisualStudio.DTE.10.0" );
            Console.WriteLine( "The Edition is " + MyDte.Edition );
            
            Console.ReadLine( );

            Console.Write( MyDte.ActiveDocument.Selection.Text );
            
            
            Console.Read( );                                                                           
        }
    
    }


note I added the references that visual studio macros uses:

![enter image description here][1]

-----

Edit
----

Maybe I get an exception because I am trying to modify the document that I am currently debugging. If I could manage to get the dte of a second instance of visual studio document ( document that is not being debuged ) I might be able to solve this problem.


  [1]: http://i.stack.imgur.com/aiiUR.png