.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Runs great in Debug, but not in Release

1 REPLY 1
Reply
Message 1 of 2
Anonymous
214 Views, 1 Reply

Runs great in Debug, but not in Release

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
1 REPLY 1
Message 2 of 2
acedmond
in reply to: Anonymous

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost