Saturday, March 24, 2012

StringWriter object and dispose method

Re hello,

I m' sorry for my questions ..
Under framework 1.1 with vb.net, i m using a StringWriter object to export
in .xls file.
To empty memory, I would like to use the propterty dispose on the object
StringWriter.
But i have received an error like this :

example :

Dim myStringWriter As System.IO.StringWriter = New System.IO.StringWriter
...
myStringWriter.Dispose(System.Boolean)(true)
myStringWriter=Nothing

Quote:

Originally Posted by

Quote:

Originally Posted by

>Error


BC30390: 'System.IO.StringWriter.Protected Overrides Sub Dispose(disposing
As Boolean)' is not accessible in that context. it is protected..

I can use the Close() method but i m not sure that this last one have the
same effects for Garbage Collector ?
Is it possible to use Dispose method with StringWriter object

Thanks for you help
fabriceUse Close(). Setting the objec to null stops the object from being
referenced, so the GC will clear it out when it's ready. Note that Dispose
DOES not remove the object from memory.

http://msdn.microsoft.com/msdnmag/issues/1100/gci/
"fabrice" <emouchet@.test.comwrote in message
news:Os20oF$BHHA.4472@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Re hello,
>
I m' sorry for my questions ..
Under framework 1.1 with vb.net, i m using a StringWriter object to export
in .xls file.
To empty memory, I would like to use the propterty dispose on the object
StringWriter.
But i have received an error like this :
>
example :
>
Dim myStringWriter As System.IO.StringWriter = New System.IO.StringWriter
...
myStringWriter.Dispose(System.Boolean)(true)
myStringWriter=Nothing
>

Quote:

Originally Posted by

Quote:

Originally Posted by

>>Error


>
BC30390: 'System.IO.StringWriter.Protected Overrides Sub Dispose(disposing
As Boolean)' is not accessible in that context. it is protected..
>
>
I can use the Close() method but i m not sure that this last one have the
same effects for Garbage Collector ?
Is it possible to use Dispose method with StringWriter object
>
>
Thanks for you help
fabrice
>


Great.
Thanks for you help.
have a nice day

"Dan Bass" <naa crit dans le message de news:
%23mDFZP$BHHA.3540@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>
Use Close(). Setting the objec to null stops the object from being
referenced, so the GC will clear it out when it's ready. Note that Dispose
DOES not remove the object from memory.
>
http://msdn.microsoft.com/msdnmag/issues/1100/gci/
>
>
>
"fabrice" <emouchet@.test.comwrote in message
news:Os20oF$BHHA.4472@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Re hello,
>>
>I m' sorry for my questions ..
>Under framework 1.1 with vb.net, i m using a StringWriter object to
>export in .xls file.
>To empty memory, I would like to use the propterty dispose on the object
>StringWriter.
>But i have received an error like this :
>>
>example :
>>
>Dim myStringWriter As System.IO.StringWriter = New System.IO.StringWriter
>...
>myStringWriter.Dispose(System.Boolean)(true)
>myStringWriter=Nothing
>>

Quote:

Originally Posted by

>>>Error


>>
>BC30390: 'System.IO.StringWriter.Protected Overrides Sub
>Dispose(disposing As Boolean)' is not accessible in that context. it is
>protected..
>>
>>
>I can use the Close() method but i m not sure that this last one have the
>same effects for Garbage Collector ?
>Is it possible to use Dispose method with StringWriter object
>>
>>
>Thanks for you help
>fabrice
>>


>
>


remember that you also don't need <myObject= Nothing explicitly in order
for the GC to clean the object up, although it is (IMO) good coding
practice.

"fabrice" <emouchet@.test.comwrote in message
news:ewVgTr$BHHA.4928@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Great.
Thanks for you help.
have a nice day
>
"Dan Bass" <naa crit dans le message de news:
%23mDFZP$BHHA.3540@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>>
>Use Close(). Setting the objec to null stops the object from being
>referenced, so the GC will clear it out when it's ready. Note that
>Dispose DOES not remove the object from memory.
>>
>http://msdn.microsoft.com/msdnmag/issues/1100/gci/
>>
>>
>>
>"fabrice" <emouchet@.test.comwrote in message
>news:Os20oF$BHHA.4472@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>>Re hello,
>>>
>>I m' sorry for my questions ..
>>Under framework 1.1 with vb.net, i m using a StringWriter object to
>>export in .xls file.
>>To empty memory, I would like to use the propterty dispose on the object
>>StringWriter.
>>But i have received an error like this :
>>>
>>example :
>>>
>>Dim myStringWriter As System.IO.StringWriter = New
>>System.IO.StringWriter
>>...
>>myStringWriter.Dispose(System.Boolean)(true)
>>myStringWriter=Nothing
>>>
>>>>Error
>>>
>>BC30390: 'System.IO.StringWriter.Protected Overrides Sub
>>Dispose(disposing As Boolean)' is not accessible in that context. it is
>>protected..
>>>
>>>
>>I can use the Close() method but i m not sure that this last one have
>>the same effects for Garbage Collector ?
>>Is it possible to use Dispose method with StringWriter object
>>>
>>>
>>Thanks for you help
>>fabrice
>>>


>>
>>


>
>


Thanks Dan.

"Dan Bass" <naa crit dans le message de news:
OgD8SCACHHA.3380@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

remember that you also don't need <myObject= Nothing explicitly in order
for the GC to clean the object up, although it is (IMO) good coding
practice.
>
"fabrice" <emouchet@.test.comwrote in message
news:ewVgTr$BHHA.4928@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>Great.
>Thanks for you help.
>have a nice day
>>
>"Dan Bass" <naa crit dans le message de news:
>%23mDFZP$BHHA.3540@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>>>
>>Use Close(). Setting the objec to null stops the object from being
>>referenced, so the GC will clear it out when it's ready. Note that
>>Dispose DOES not remove the object from memory.
>>>
>>http://msdn.microsoft.com/msdnmag/issues/1100/gci/
>>>
>>>
>>>
>>"fabrice" <emouchet@.test.comwrote in message
>>news:Os20oF$BHHA.4472@.TK2MSFTNGP03.phx.gbl...
>>>Re hello,
>>>>
>>>I m' sorry for my questions ..
>>>Under framework 1.1 with vb.net, i m using a StringWriter object to
>>>export in .xls file.
>>>To empty memory, I would like to use the propterty dispose on the
>>>object StringWriter.
>>>But i have received an error like this :
>>>>
>>>example :
>>>>
>>>Dim myStringWriter As System.IO.StringWriter = New
>>>System.IO.StringWriter
>>>...
>>>myStringWriter.Dispose(System.Boolean)(true)
>>>myStringWriter=Nothing
>>>>
>>>>>Error
>>>>
>>>BC30390: 'System.IO.StringWriter.Protected Overrides Sub
>>>Dispose(disposing As Boolean)' is not accessible in that context. it is
>>>protected..
>>>>
>>>>
>>>I can use the Close() method but i m not sure that this last one have
>>>the same effects for Garbage Collector ?
>>>Is it possible to use Dispose method with StringWriter object
>>>>
>>>>
>>>Thanks for you help
>>>fabrice
>>>>
>>>
>>>


>>
>>


>
>

0 comments:

Post a Comment