StringWriter object and dispose method

Discussion in 'ASP .Net' started by fabrice, Nov 14, 2006.

  1. fabrice

    fabrice Guest

    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
     
    fabrice, Nov 14, 2006
    #1
    1. Advertising

  2. fabrice

    Dan Bass Guest

    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" <> wrote in message
    news:Os20oF$...
    > 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
    >
     
    Dan Bass, Nov 14, 2006
    #2
    1. Advertising

  3. fabrice

    fabrice Guest

    Great.
    Thanks for you help.
    have a nice day

    "Dan Bass" <na> a écrit dans le message de news:
    %23mDFZP$...
    >
    > 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" <> wrote in message
    > news:Os20oF$...
    >> 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
    >>

    >
    >
     
    fabrice, Nov 14, 2006
    #3
  4. fabrice

    Dan Bass Guest

    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" <> wrote in message
    news:ewVgTr$...
    > Great.
    > Thanks for you help.
    > have a nice day
    >
    > "Dan Bass" <na> a écrit dans le message de news:
    > %23mDFZP$...
    >>
    >> 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" <> wrote in message
    >> news:Os20oF$...
    >>> 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
    >>>

    >>
    >>

    >
    >
     
    Dan Bass, Nov 14, 2006
    #4
  5. fabrice

    fabrice Guest

    Thanks Dan.


    "Dan Bass" <na> a écrit dans le message de news:
    ...
    > 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" <> wrote in message
    > news:ewVgTr$...
    >> Great.
    >> Thanks for you help.
    >> have a nice day
    >>
    >> "Dan Bass" <na> a écrit dans le message de news:
    >> %23mDFZP$...
    >>>
    >>> 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" <> wrote in message
    >>> news:Os20oF$...
    >>>> 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
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    fabrice, Nov 15, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Antonio Concepcion
    Replies:
    3
    Views:
    2,849
    Antonio Concepcion
    Feb 17, 2005
  2. Replies:
    1
    Views:
    793
    intrader
    Jun 17, 2005
  3. darrel
    Replies:
    3
    Views:
    668
    Cowboy \(Gregory A. Beamer\)
    Mar 27, 2007
  4. Replies:
    6
    Views:
    8,582
    Tom Anderson
    Mar 30, 2009
  5. Tomas Mikula
    Replies:
    3
    Views:
    1,795
    Arne Vajhøj
    Nov 21, 2009
Loading...

Share This Page