TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nepethya Rana
NA
335
151.5k
ObjectDisposedException
May 14 2017 11:35 PM
Hi,
I got randomly Object disposed exception in my application 1 out of 5 times if I ran the program. It does not throw exceptions every time i ran the program.
stacktrace says the exception is occured at the line where file1 = nothing.
How do i solve this erratick behaviour ?
Better way to implemt the code?
Dim sbSQL As New StringBuilder
sbSQL.Append("SELECT Item_Id from MyTableA")
Dim ds1 As New DataSet
Using daFindOutdated As New SqlDataAdapter(sbSQL.ToString, cn)
daFindOutdated.Fill(ds1)
End Using
Dim sbPath As New StringBuilder
For Each row As DataRow In ds1.Tables(0).Rows
sbPath.Append(ConfigurationManager.AppSettings("ZipFilePath") & "TBL" & row.Item("Item_ID").ToString.PadLeft(5, "0") & ".zip")
If File.Exists(sbPath.ToString) Then
Dim zip As New ZipArchive(New DiskFile(sbPath.ToString))
Dim folder1 As AbstractFolder = zip.GetFolder("\Item\File\")
Dim file1 As AbstractFile = folder1.GetFile("Tbl.cpf")
Using sw1 As New StreamWriter(file1.OpenWrite(True))
sw1.AutoFlush = True
sw1.WriteLine("")
sw1.Close()
file1 = Nothing
End Using
Dim folder2 As AbstractFolder = zip.GetFolder("\Item\File\")
Dim file2 As AbstractFile = folder2.GetFile("Tbl.cmp")
Using sw2 As New StreamWriter(file2.OpenWrite(True))
sw2.AutoFlush = True
sw2.WriteLine("")
sw2.Close()
file2 = Nothing
End Using
Dim folder3 As AbstractFolder = zip.GetFolder("\Item\File\")
Dim file3 As AbstractFile = folder3.GetFile("Tbl.upc")
Using sw3 As New StreamWriter(file3.OpenWrite(True))
sw3.AutoFlush = True
sw3.WriteLine("")
sw3.Close()
file3 = Nothing
End Using
zip = Nothing
End If
sbPath.Length = 0
Next
Reply
Answers (
1
)
trying to understand recursion
how to prevent the page during the submit event