Author Topic: AutoCAD 2011 Mechanical selection crash  (Read 2870 times)

0 Members and 1 Guest are viewing this topic.

jlatimer11

  • Mosquito
  • Posts: 13
AutoCAD 2011 Mechanical selection crash
« on: January 19, 2011, 01:21:50 PM »
AutoCAD 2011 Mechanical
VB.NET 2008 Express
.net Framework 3.5
Windows 7 Professional

Not sure why this is happening. Any type of code requiring someone to choose an object crashes upon run every time. I've looked up the error code (e0434f4dh) and it seems to point to a .net Framework issue.

The issue with this is that I'm running Windows 7, so that means I can't just uninstall and re-install .net Framework on a whim since it is installed at OS setup. I've re-installed AutoCAD from scratch and I've tried the .net cleanup tool, and both have not worked.

Here is the code I've been attempting to use:

Code: [Select]
Dim myDB As DatabaseServices.Database
Dim myDWG As ApplicationServices.Document
Dim myEd As EditorInput.Editor
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim MySelObj As DatabaseServices.DBObject
Dim myPNER As EditorInput.PromptNestedEntityResult
Dim myAttRef As DatabaseServices.AttributeReference

myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
myDB = myDWG.Database
myEd = myDWG.Editor
myPNER = myEd.GetNestedEntity("Select an attribute: ")
If IsNothing(myPNER.ObjectId) = False Then
myTransMan = myDWG.TransactionManager
myTrans = myTransMan.StartTransaction
MySelObj = myPNER.ObjectId.GetObject(DatabaseServices.OpenMode.ForRead)
If TypeOf MySelObj Is DatabaseServices.AttributeReference Then
myAttRef = MySelObj
MsgBox(myAttRef.Tag & " = " & myAttRef.TextString)
Else
MsgBox("You didn't select an Attribute." & vbCr & _
"You selected a" & vbCr & MySelObj.ToString.ToUpper)
End If

myTrans.Dispose()
myTransMan.Dispose()
End If

If I comment out the 'myPNER' line, the code does nothing, but AutoCAD does not crash.

kaefer

  • Guest
Re: AutoCAD 2011 Mechanical selection crash
« Reply #1 on: January 19, 2011, 05:09:10 PM »
error code (e0434f4dh)

By any chance, that wasn't "Unhandled e0434f4dh exception" or something?  Look's more like an address...

Quote
The issue with this is that

- you have no Try Catch block on your own, which could inform you about exceptions caught.
- you haven't produced an error report (dmpuserinfo.xml in your temp dir might contain more info)
- looking at your code, a few thing strike me as non-standard:
Quote
Code: [Select]
If IsNothing(myPNER.ObjectId) = False Then
The customary way to check for success of ed.GetXXX() methods is by PromptStatus.
Code: [Select]
If (myPNER.Status = PromptStatus.OK)  Then
Quote
Code: [Select]
myTrans.Dispose()
It is considered good manners to commit as well, and wrap the scope with Try/Finally.
Code: [Select]
Try
    ...
    myTrans.Commit()
Finally
    myTrans.Dispose()
Quote
Code: [Select]
myTransMan.Dispose()
Why would you want to do that?

Glenn R

  • Guest
Re: AutoCAD 2011 Mechanical selection crash
« Reply #2 on: January 19, 2011, 05:22:38 PM »
You should never be calling Dispose() on the TransactionManager. You didn't create it, so leave it alone.

Glenn R

  • Guest
Re: AutoCAD 2011 Mechanical selection crash
« Reply #3 on: January 19, 2011, 05:25:14 PM »
Also, as kaefer mentioned, you should be calling Commit() on the transaction you created and started, otherwise a rollback will be initiated, which can be expensive as well as undesireable, depending on what you're doing.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AutoCAD 2011 Mechanical selection crash
« Reply #4 on: January 19, 2011, 06:53:11 PM »
James, Welcome to the Swamp.

Also;
To save your sanity later,
get into the habit of using Option Explicit and Option Strict with your code.
Type safety is something you will want to take control of sooner or later and it may as well be sooner ... instead of relying on the VB IDE to change your code behind the scenes at compile time to force it to conform to what it assumes are your intentions.

Regards
Kerry
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jlatimer11

  • Mosquito
  • Posts: 13
Re: AutoCAD 2011 Mechanical selection crash
« Reply #5 on: January 19, 2011, 07:21:20 PM »
I apologize for the crude code, but I'm using a guide book since I'm very unfamiliar with VB.NET.

The error was definitely 'Unhandled e0434f4dh exception', which I found out was because my source files were on a network share. Once I took them off the crashes stopped.

Thanks for the info on transactions. They are the one thing going from VBA to VB.NET that  I can't wrap my head around yet.  :-)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AutoCAD 2011 Mechanical selection crash
« Reply #6 on: January 19, 2011, 08:54:45 PM »

James,
yes, I recognised the code style from the book. :)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.