473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

IDispose grrrrrr

JP
Ok, Im at my wits end with trying to dispose of this class. Everything I try
either doesnt dispose the class or I get build error. Im using C#. What Im I
doing wrong?

XHTML_Library objXHTMLHolder = new XHTML_Library();
objXHTMLHolder.Method...
..
..
objXHTMLHolder.Method...
..
..
objXHTMLHolder.DisposeMyClass();
Response.End();
======================
public class XHTML_Library : XmlDocument //want to dispose the whole class
{
..
..
..
public void DisposeMyClass()

{
//im sure issue is here. How to I properly call IDispose here??
this.Dispose();
}

}
--
JP
..NET Software Develper
Jul 21 '05 #1
3 1522
Try declaring your class like this to expose the IDisposable interface

public class XHTML_Library : XmlDocument, IDisposable

Jul 21 '05 #2
JP
If I place just before the Response.End() I get:
Exception of type System.StackOverflowException was thrown.

XHTML_Library objXHTMLHolder = new XHTML_Library();
..
..
..
objXHTMLHolder.Dispose();
Response.End();
================================
public class XHTML_Library : XmlDocument,IDisposable
{
public void Dispose()
{
Dispose();
GC.SuppressFinalize(this);
}
}

"Jamin Guy" wrote:
Try declaring your class like this to expose the IDisposable interface

public class XHTML_Library : XmlDocument, IDisposable

Jul 21 '05 #3
The overflow exception is because you are calling Dispose from within itself,
so it is obviously recursive.

The question is, why does your class need a dispose method? Does it contain
unmanaged members, or members that require disposing? If so, then this clean
up should be called within Dispose. Implementing a Dispose method and calling
it in itself does not do anything.

Might be worth reading up on the Dispose pattern to make sure you need it
and fully understand it.

HTH
Dan

"JP" wrote:
If I place just before the Response.End() I get:
Exception of type System.StackOverflowException was thrown.

XHTML_Library objXHTMLHolder = new XHTML_Library();
.
.
.
objXHTMLHolder.Dispose();
Response.End();
================================
public class XHTML_Library : XmlDocument,IDisposable
{
public void Dispose()
{
Dispose();
GC.SuppressFinalize(this);
}
}

"Jamin Guy" wrote:
Try declaring your class like this to expose the IDisposable interface

public class XHTML_Library : XmlDocument, IDisposable

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Alvin Bruney [MVP] | last post by:
with the using construct, exit from scope calls dispose on said object. But what happens in a connection pooling scenario? Is the run-time smart enough to realize that Object Pooling is being used...
1
by: Cider123 | last post by:
Ran across some code on the net that incorporates "dispose" 2 different ways.. I understand a calling routine could use the .Dispose on your class, but I was under the impression "Dispose()" was...
15
by: Sam Sungshik Kong | last post by:
Hello! A disposable object's Dispose() method can be called either explicitly by the programmer or implicitly during finalization. If you call Dispose, the unmanaged resources are released...
14
by: MuZZy | last post by:
Hi, Lately i've been (and still am) fixing some memory leaks problems in the project i just took over when i got this new job. Among the other issues i've noticed that for localy created objects...
3
by: trialproduct2004 | last post by:
hi all can some one tell me how to call dispose method of webresponse. I am currently using close method. But this is creating problem. So i want to use dispose method of webresponse. Can some...
2
by: ssg31415926 | last post by:
If I have a class which wraps a class which implements IDisposable, should I implement IDisposable, too, in the wrapping class, and call the wrapped class Dispose() from the wrapping class...
1
by: Lasse Edsvik | last post by:
Hello I'm trying to create a class that uses northwind database and use the IDisposable interface thingy :) Can someone explain why I get: Error 1 'Procent.DataJox.Northwind' does not...
3
by: JP | last post by:
Ok, Im at my wits end with trying to dispose of this class. Everything I try either doesnt dispose the class or I get build error. Im using C#. What Im I doing wrong? XHTML_Library...
1
by: Izzy | last post by:
Here is the code. Dim conExcel As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ExcelPath & ";Extended Properties=""Excel 8.0;HDR=NO;""" Dim cmdOLE As OleDb.OleDbCommand Dim conOLE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.