473,325 Members | 2,774 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,325 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 1520
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.