PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework ObjectDisposedException

Reply

ObjectDisposedException

 
Thread Tools Rate Thread
Old 29-06-2006, 05:52 PM   #1
HW
Guest
 
Posts: n/a
Default ObjectDisposedException


Hi, I'm seeing an ObjectDisposedException inside the Watch variable
of my FileStream object, the code is here dead simple when i Close the
Filestream object it doesn't get set to Nothing although the BinaryReader
object does get set to Nothing, what's wrong?

Dim FS As System.IO.FileStream
Dim BR As System.IO.BinaryReader

FS = File.OpenRead("Image.udb")

BR = New BinaryReader(FS)

Data = BR.ReadBytes(Length)

-------

FS.Close() Inside FS watch variable see ObjectDisposedException and FS is
NOT nothing

BR.Close() BR set to Nothing after this


















  Reply With Quote
Old 29-06-2006, 06:03 PM   #2
Guest
 
Posts: n/a
Default Re: ObjectDisposedException

Try a little punctuation - I'm really not sure what you're saying or asking.

-Chris



"HW" <hw@hotmail.com> wrote in message
news:%23QgBAQ5mGHA.192@TK2MSFTNGP03.phx.gbl...
> Hi, I'm seeing an ObjectDisposedException inside the Watch variable
> of my FileStream object, the code is here dead simple when i Close the
> Filestream object it doesn't get set to Nothing although the BinaryReader
> object does get set to Nothing, what's wrong?
>
> Dim FS As System.IO.FileStream
> Dim BR As System.IO.BinaryReader
>
> FS = File.OpenRead("Image.udb")
>
> BR = New BinaryReader(FS)
>
> Data = BR.ReadBytes(Length)
>
> -------
>
> FS.Close() Inside FS watch variable see ObjectDisposedException and FS
> is NOT nothing
>
> BR.Close() BR set to Nothing after this
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



  Reply With Quote
Old 29-06-2006, 06:11 PM   #3
HW
Guest
 
Posts: n/a
Default Re: ObjectDisposedException

Sorry, i'm wondering why i am seeing an ObjectDisposedException
when i close the FS object. When i have FS set as a watch variable
in the debugger i see the exception inside the variable and it dosen't get
set to Nothing and is still pointing to an object after executing FS.Close
statement.

The BR object is correctly disposed. SO i'm wondering why the FS object
is not correctly disposed. The code looks ok to me.


"<ctacke/>" <ctacke[@]opennetcf[dot]com> wrote in message
news:uxxFWW5mGHA.4212@TK2MSFTNGP04.phx.gbl...
> Try a little punctuation - I'm really not sure what you're saying or
> asking.
>
> -Chris
>
>
>
> "HW" <hw@hotmail.com> wrote in message
> news:%23QgBAQ5mGHA.192@TK2MSFTNGP03.phx.gbl...
>> Hi, I'm seeing an ObjectDisposedException inside the Watch variable
>> of my FileStream object, the code is here dead simple when i Close the
>> Filestream object it doesn't get set to Nothing although the BinaryReader
>> object does get set to Nothing, what's wrong?
>>
>> Dim FS As System.IO.FileStream
>> Dim BR As System.IO.BinaryReader
>>
>> FS = File.OpenRead("Image.udb")
>>
>> BR = New BinaryReader(FS)
>>
>> Data = BR.ReadBytes(Length)
>>
>> -------
>>
>> FS.Close() Inside FS watch variable see ObjectDisposedException and FS
>> is NOT nothing
>>
>> BR.Close() BR set to Nothing after this
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>

>
>



  Reply With Quote
Old 30-06-2006, 01:13 PM   #4
HW
Guest
 
Posts: n/a
Default Re: ObjectDisposedException

It is getting thrown as inner exception. How does one go about
solving inner exceptions?


"HW" <hw@hotmail.com> wrote in message
news:%23ez0fa5mGHA.2252@TK2MSFTNGP04.phx.gbl...
> Sorry, i'm wondering why i am seeing an ObjectDisposedException
> when i close the FS object. When i have FS set as a watch variable
> in the debugger i see the exception inside the variable and it dosen't get
> set to Nothing and is still pointing to an object after executing FS.Close
> statement.
>
> The BR object is correctly disposed. SO i'm wondering why the FS object
> is not correctly disposed. The code looks ok to me.
>
>
> "<ctacke/>" <ctacke[@]opennetcf[dot]com> wrote in message
> news:uxxFWW5mGHA.4212@TK2MSFTNGP04.phx.gbl...
>> Try a little punctuation - I'm really not sure what you're saying or
>> asking.
>>
>> -Chris
>>
>>
>>
>> "HW" <hw@hotmail.com> wrote in message
>> news:%23QgBAQ5mGHA.192@TK2MSFTNGP03.phx.gbl...
>>> Hi, I'm seeing an ObjectDisposedException inside the Watch variable
>>> of my FileStream object, the code is here dead simple when i Close the
>>> Filestream object it doesn't get set to Nothing although the
>>> BinaryReader
>>> object does get set to Nothing, what's wrong?
>>>
>>> Dim FS As System.IO.FileStream
>>> Dim BR As System.IO.BinaryReader
>>>
>>> FS = File.OpenRead("Image.udb")
>>>
>>> BR = New BinaryReader(FS)
>>>
>>> Data = BR.ReadBytes(Length)
>>>
>>> -------
>>>
>>> FS.Close() Inside FS watch variable see ObjectDisposedException and FS
>>> is NOT nothing
>>>
>>> BR.Close() BR set to Nothing after this
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off