Debug custom dll that is being referenced in visual studio macro

Viewed 1508

I previously asked: Add dll reference to visual studio macros

the idea of creating the macros in my language (C#) makes it easier to create the macros. The problem is that I cannot debug the dll

To solve the problem I have tried:

  1. I placed myClassLibrary.pdb next to myClassLibrary.dll hoping I where going to be able to debug the methods in the dll by steping in to them.

  2. Created a WCF service. Because I did not knew how to reference the service from vba I reference it from the class library. The problem is that I need to use variables such as DTE.ActiveDocument and those variables are not serializable meaning I could not pass them to the wcf service.

the idea of working in C# is very nice but not being able to debug and see what is going on makes it somewhat difficult. I might have to go to my older option where I created my code on C# compiled then decompiled into vba with reflector.


Edit

I think I am close on getting a solution. I thought why not create the macro in a console application? I am able to get the active document text but not able to change it.

        EnvDTE80.DTE2 MyDte;
        MyDte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject( "VisualStudio.DTE.10.0" );
        Console.WriteLine( "The Edition is " + MyDte.Edition );

        Console.ReadLine( );

        // write to the console the text that is selected. "sometimes it does not work don't know why"
        Console.WriteLine(
            MyDte.ActiveDocument.Selection.Text
        );

note I added the following references plus the onces that vba macros have:

enter image description here

5 Answers
Related