Crashing AutoCAD using .NET

I'm still mainly on holiday this week, so this is a really silly post that I don't realistically expect to be of use to anyone. But then you never know. 🙂

A colleague in Product Support asked me for a quick way to cause AutoCAD to crash, the other day. I didn't ask too much about why he needed to – I trusted he had his reasons – and so went ahead and gave it a try.

One very standard way to cause software to crash – at least software that is either written using a pointer-friendly programming language or implements a plugin model that can load in-process modules that are – is to dereference a null pointer. My first thought was to attempt to do this in LISP, whether by applying a nil pointer as a lambda function or something along those lines. I didn't have much, though, and neither did I find an undocumented "CRASH" command that could be used, so I ended up implementing something very simple in C#.

And here it is:

using Autodesk.AutoCAD.Runtime;

 

namespace CrashAutoCAD

{

  public class Commands

  {

    [CommandMethod("CRASH")]

    static public void Crash()

    {

      object o = null;

      o.ToString();

    }

  }

}

When we run our CRASH command we see this:

Crash

And then, predictably enough, this:

CER dialog

If any of you have tricks to crash AutoCAD that doesn't involve a plugin, please do let me know – I'd be interested to hear about them.

4 responses to “Crashing AutoCAD using .NET”

  1. Got a bunch for starters create layer filter with same properties in picture
    i1221.photobucket.com/albums/dd473/Jeffrey_H/LayerFilter_zpsee76d897.png

    Click Ok and BANG!

  2. Thanks - I can indeed see the bang. I'll take a look and make sure this one's been logged.

    Kean

  3. Create some overlapping geometry preferably attributed blocks. Then try to hatch an area inside one of them. Most probably your machine will get frozen! Pressing any key afterwards, will bring you the crash error report sending screen !

    Out of experience, I would ALWAYS press QSAVE before proceeding with hatches.

  4. huaxiamengqing Avatar

    VBASTMT
    do:loop
    --

Leave a Reply

Your email address will not be published. Required fields are marked *