Nick Gilbert
Nick Gilbert

Reputation: 4240

Fatal Error: Unhandled Access Exception in AutoCAD C#.NET plugin

I'm writing a plugin that is supposed to read data from a binary file on startup. Upon starting up it is supposed to read the data from the file and ask the user to select a location to display the data in the table. The plugin is supposed to programmatically minimize the form and then ask the user in AutoCAD's command line to select the point where the table is supposed to be

WindowsDoors f = (WindowsDoors)WindowsDoors.ActiveForm;
f.WindowState = FormWindowState.Minimized;
pr = ed.GetPoint("\nEnter table insertion point: ");

However, upon trying to execute the middle line of code shown to minimize the form, AutoCAD crashes with a dialog box saying "FATAL ERROR: Unhandled Access Violation Reading 0x0000 Exception at 206206edh"

I suspect I have to programmatically set the WindowsDoors f object to be ok with being messed with programmatically but am not sure if I am right or how to do that if I am

Upvotes: 3

Views: 1737

Answers (1)

Augusto Goncalves
Augusto Goncalves

Reputation: 8574

From inside a form, if you want to go back to the editor, you'll need to call

Editor.StartUserInteraction(this)

Where this is the active form. That will hide the form and set the focus back to AutoCAD.

See a sample at http://adndevblog.typepad.com/autocad/2012/05/taking-mouse-inputs-from-a-modal-dialog-box.html

Upvotes: 1

Related Questions