I hope this helps.....
Dim newXDb As Database = New Database(False, True)
newXDb.ReadDwgFile(strfilepath, System.IO.FileShare.ReadWrite, False, "")
Dim xrefTr As Transaction = newXDb.TransactionManager.StartTransaction()
Using xrefTr
Dim bTable As BlockTable = xrefTr.GetObject(newXDb.BlockTableId, OpenMode.ForWrite)
Dim bRecord As BlockTableRecord = xrefTr.GetObject(bTable(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim iter As IEnumerator = bRecord.GetEnumerator
Dim i As Integer = 0
While iter.MoveNext
Dim id As ObjectId = iter.Current
Dim ent As Entity = CType(xrefTr.GetObject(id, OpenMode.ForWrite), Entity)
If (TypeOf ent Is BlockReference) Then
Dim bref As BlockReference = CType(xrefTr.GetObject(ent.ObjectId, OpenMode.ForWrite), BlockReference)
Dim blkRec As BlockTableRecord = CType(xrefTr.GetObject(bref.BlockTableRecord, OpenMode.ForRead), BlockTableRecord)
If blkRec.IsFromExternalReference Then
If bref.IsWriteEnabled = True Then
bref.Erase()
bref.Dispose()
i += 1
End If
ent.Dispose()
End If
End If
End While
MsgBox("Blocks deleted: " & i)
xrefTr.Commit()
newXDb.SaveAs(strfilepath, DwgVersion.Current)
xrefTr.Dispose()
newXDb.Dispose()
End Using