*Ben Rand
Message 1 of 2 (90 Views)

Runs great in Debug, but not in Release

90 Views, 1 Replies
12-23-2005 07:39 AM
Very new to VB.NET. I have a small application (rewritten from a sample I
found) that detaches images from a drawing if they are not loaded, given a
portion of the image's filename. I'm using VS 2005 and Autocad 2006,
although the same behavior also occurs if I try to build/run the app from VS

The application runs fine in Debug mode, correctly detaching all of several
images that meet the filename criteria. When I build the application, start
Autocad normally, netload the dll, and run the application, it detaches one
of the images, then refuses to remove any others. I don't understand why
this is happening. I've copied the source code below.

Public Sub KillImage(ByVal ImageName As String)
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim nod As DBDictionary
Dim imageDict As DBDictionary
Dim dictEntry As System.Collections.DictionaryEntry
Dim rastImageDef As RasterImageDef
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager =
Dim trans As Autodesk.AutoCAD.DatabaseServices.Transaction =
nod = tm.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead, False)
imageDict = tm.GetObject(nod.GetAt("ACAD_IMAGE_DICT"), OpenMode.ForRead,
For Each dictEntry In imageDict
Dim obj As DBObject
obj = tm.GetObject(dictEntry.Value(), OpenMode.ForWrite, False)
If TypeOf obj Is RasterImageDef Then
Dim imagePath As String
rastImageDef = CType(obj, RasterImageDef)
' see if the image path is right
imagePath = rastImageDef.SourceFileName
If imagePath.IndexOf(ImageName, StringComparison.OrdinalIgnoreCase)
> -1 Then
If rastImageDef.IsLoaded = False Then
End If
End If
End If
'aborts (or causes a "rollback" of) the transaction
If (Not trans Is Nothing) Then
End If
End Try
End Sub

Thanks for any help,

Ben Rand
CAD Manager
CEntry Constructors & Engineers
Active Member
Posts: 9
Registered: ‎06-15-2006
Message 2 of 2 (90 Views)

Re: Runs great in Debug, but not in Release

07-07-2006 07:28 AM in reply to: *Ben Rand
Did you ever get this figured out. I'm have some what of the same problem, but mine happens when I try to open a drawing.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.