In the past C++/C era, it was very easy to crash AutoCAD or even the whole Operating System. Now in the .NET time, it is harder, much harder than before, but we still can find various ways to crash AutoCAD using its .NET API, from the easiest or most common to quite hard or very creative.
Now and then, we need to create side Database instances and operate on them such as creating a new DWG file and reading an existing one from disk into memory. However, if not carefully looking at things in detail, we may crash AutoCAD hard with a couple of very simple lines of code:
public static void Crash15_Method()
Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
using (Database db = new Database(false, true))
catch (System.Exception ex)
After the assembly is loaded into AutoCAD and the command is run, an AutoCAD Error Aborting dialog saying ‘FATAL ERROR: Unhandled Access Violation Reading 0x0020 Exception at e080410dh’ would come up:
Note please that the memory address in the message may be different each time but the crash will not be missing.
The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides project wizards in C#, VB.NET and CLI/Managed C++, and various item wizards such as Event Handlers, Command/LispFunction Definers, and Entity/Draw Jiggers in both C# and VB.NET, to help program AutoCAD addins.