.NET

Reply
*Ben Rand
Message 1 of 2 (87 Views)

Runs great in Debug, but not in Release

87 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
2003.

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 =
db.TransactionManager()
Dim trans As Autodesk.AutoCAD.DatabaseServices.Transaction =
tm.StartTransaction()
Try
nod = tm.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead, False)
imageDict = tm.GetObject(nod.GetAt("ACAD_IMAGE_DICT"), OpenMode.ForRead,
False)
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
obj.Erase()
End If
End If
End If
Next
trans.Commit()
Catch
'aborts (or causes a "rollback" of) the transaction
trans.Abort()
Finally
If (Not trans Is Nothing) Then
trans.Dispose()
End If
End Try
End Sub

Thanks for any help,

Ben Rand
CAD Manager
CEntry Constructors & Engineers
brand@centry.net
Active Member
acedmond
Posts: 9
Registered: ‎06-15-2006
Message 2 of 2 (87 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.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.