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.
From this post on, let us see kinds of ways to crash AutoCAD with its .NET API. Trying to access the AutoCAD object or entity after it being disposed is another easy and common way to crash AutoCAD.
[CommandMethod("CrashAutoCAD2", CommandFlags.Modal)]
public static void CrashAutoCAD2_Method()
{
ObjectId id = Autodesk.AutoCAD.Internal.Utils.EntLast();
Entity ent = (Entity)id.Open(OpenMode.ForWrite);
ent.ColorIndex = 5;
ent.Dispose();
int color = ent.ColorIndex;
}
After the assembly is load into AutoCAD, an entity added to the database, and the test command run, a FATAL ERROR: Unhandled Access Violation Reading message with the title AutoCAD Error Aborting will show up:
Give it a try and you will not miss it! More ways, some of which are pretty creative, will be demonstrated in the future. Please stay tuned.
The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides various project wizards, item wizards, coders and widgets to help program AutoCAD .NET addins.
Posted by: |