Kean Walmsley

  • About the Author
    Kean on Google+

April 2014

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      

« Extending a set of AutoCAD lines using .NET | Main | Debugging into AutoCAD’s .NET API layer using Reflector – Part 2 »

February 03, 2010

Debugging into AutoCAD’s .NET API layer using Reflector – Part 1

As many of you will know, by now, I’m a big fan of Reflector. I’ve used it for quite some time, since its early days as a piece of freeware developed by Lutz Roeder, and overall it’s proven to be an extremely valuable tool. When a UK-based company, Red Gate Software, acquired the Reflector technology back in 2008, I was curious as to their strategy for monetizing it (and it seems I wasn’t alone in speculating on the direction the tool would take as a commercial offering). Well, that’s now starting to become clear with the Beta release of .NET Reflector Pro.

Here’s the tag-line on Red Gate’s website for this new version:

.NET Reflector Pro integrates .NET Reflector into Visual Studio to allow you to seamlessly debug into third-party code and assemblies, even if you don't have the source code for them. You can now treat decompiled assemblies much like your own code: you can step through the assemblies and use all the debugging techniques that you would use on your own code.

This blog article on Red Gate’s Simple-Talk site contains some more interesting details on this version’s capabilities. Here are the two main features:

    • Letting you jump to Reflector from your code (this is free!)
    • Debugging decompiled code using the visual studio debugger (this is Reflector Pro - so will cost money)

Both of these items look pretty interesting, and – knowing that the .NET API for AutoCAD is unobfuscated, as it’s mostly a fairly thin layer on top of ObjectARX – the second (paid) feature has the potential to be of great interest to AutoCAD .NET developers.

So I decided to put the tool through its paces. After downloading the most recent external Beta (build 892), and extracting it to my hard-drive, I launched Reflector.

On the Tools menu, we see the Integration Options menu item:

Reflector 6's integration options menu item

In the options, themselves, we can see that the tool has detected the installed versions of Visual Studio on my system and has integrated itself appropriately with them:

The integration options

Now, as long as we’ve previously loaded AutoCAD’s managed assemblies inside Reflector (File –> Open, and select “acmgd.dll” and “acdbmgd.dll” from our AutoCAD installation folder), we should now be able to jump directly to the implementation of a particular method from the Visual Studio window. Let’s take the example of the method looked used in the last post, the Extend method we called on a Line:

Launching Reflector directly from Visual Studio

And when we select it, the integration takes us to the Curve class in Reflector:

Jumped to the Curve class, where Extend is implemented

From here it’s a manual operation to expand the class and select “Extend(Boolean, Point3d) : Void” from the list of methods (although I’m curious why it didn’t manage to get there itself – perhaps a minor Beta quirk).

And then we can, of course, use the standard Reflector capabilities to look into the code:

Disassembling the Curve's Extend function

Which admittedly only shows us (in this case, at least) an obscure piece of code which is actually calling through to the underlying, unmanaged, ObjectARX API:

Our disassembled method

In the second part of this two-part series, we’ll take a look at the “Pro” features of this new .NET Reflector version: the actual debugging integration.

blog comments powered by Disqus

10 Random Posts