One of the benefits of using VBA or VB6 (probably one of the very few benefits) is the ability to easily debug code. Not that it is too difficult to debug using .NET but there are a couple of tricks that you need to know. When using VBA from within RE7 you need to do very little other than set a break point where it is needed. Using VB6 plug-ins you used to be able to just run the project and start the document (until, that is Internet Explorer stopped supporting the running of these component directly).
In .NET it is not as straight forward. Either you have to create a little application that starts the form that you are using for plug-ins or for “VBA” style macros and event based customisations you need to ensure all your files are in the RE7 plugin or custom directory and attach Visual Studio to the RE7.exe process. This is done using the Tools menu item “Attach to Process”. In the list you find RE7.exe and as long as you are loading the same version of the file in RE7 as you have open in Visual Studio you are able to debug.
One of the problems with this is that it becomes slightly difficult to debug events that happen on opening of RE7 i.e. in the application start events. It is possible that you can be quick and start the Attach to Process item and select RE7 before the application has reached the custom code but it is a pain.
What is more it seemed to me that there must be a way of automating this process so that it would be much quicker. Well I got out my automation handbook and started to program (I don’t actually have an automation handbook). I put together the following macro which does the trick. I then assigned the shortcut CTRL-ALT P (you could assign whatever you like but this is one that I assigned previously to open up the attach to process window).
Sub AttachToRE7() Try Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default") Dim dbgeng(2) As EnvDTE80.Engine dbgeng(0) = trans.Engines.Item("T-SQL") dbgeng(1) = trans.Engines.Item("Managed (v2.0, v1.1, v1.0)") Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, My.Computer.Name).Item("RE7.exe") proc2.Attach2(dbgeng) Catch ex As System.Exception MsgBox(ex.Message) End Try End Sub