- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm asking user for selecting objects, then selecting a line, then selecting an text, then giving a certain point.
of course it's possible objects, a line, or a text, is not available. so user is pressing escape button.
Now when pressing escape during selecting objects, or selecting a line, the code just ends.
However, when pressing escape during selecting an mtext, it gives me a bug like:
" An unhandled exception of type 'System.AccessViolationException' occurred in AcdbMgd.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Problem is, it's a little unclear where the bug really happens, when stepping through te code it happens at the line AFTER selecting the text, doesn't matter what this next line is, or even if it has to do with the selected line.
Tried many try/catches around different parts but doesn't solve it.
Here's the code of selecting the Mtext:
private MText selecteerlegendatekst()
{
//selectieinstellingen
var Popties = new PromptEntityOptions("Selecteer bijbehorende text");
Popties.SetRejectMessage("Dit is geen Mtext");
Popties.AddAllowedClass(typeof(MText), true);
// vars instellen
var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
var dat = doc.Database;
var edi = doc.Editor;
//get polyline
var selectie = edi.GetEntity(Popties);
try
{
using (DocumentLock docLock = doc.LockDocument())
{
var tra = dat.TransactionManager.StartTransaction();
//converten text
Entity obj = (Entity)tra.GetObject(selectie.ObjectId, OpenMode.ForWrite);
MText Ltext = new MText();
if (obj.GetType() == typeof(DBText))
{
DBText dbtext = (DBText)tra.GetObject(selectie.ObjectId, OpenMode.ForWrite);
Ltext = naarMText(dbtext);
}
else
{
Ltext = (MText)tra.GetObject(selectie.ObjectId, OpenMode.ForWrite);
}
tra.Dispose();
return Ltext;
}
}
}
by the way, when Mtext is selected everything works fine.
So, anyone know what could be the problem, or more important, how to solve this?
Solved! Go to Solution.