<p>I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but at the end, I get a "Trying to use an SPWeb object that has been closed or disposed and is no longer valid." error message.</p>

<p>From what I see, SPContext.Current.Web is Disposed by someone, <strong>but I have no idea where</strong>. I just wonder: With Visual Studio 2005's Debugger, can I somehow see where/who disposed an Object? As I neither create nor have the source code, setting breakpoints is a problem.</p>

<p>What would be a good approach for finding out who disposes a given object where, without just randomly commenting out lines?</p>

<p>(Note: The Issue has been resolve, but the question itself also applies outside of Sharepoint)</p>

Check if this helps:
Add a new breakpoint using
Debug > New Breakpoint > Break at Function... (Ctrl+B)
.
Enter
Microsoft.SharePoint.SPWeb.Dispose
in the Function edit box.
Dismiss the dialog box that says that Intellisense could not find the specified location.
Run under the debugger.
When the breakpoint is hit you can see on the call stack who called the Dispose method. Hopefully for some of the times the breakpoint is hit one stack frame is in your source code.
If a dialog appears saying that
There is no source code available for the current location
when the breakpoint is hit dismiss it.
Note:
Because I do not have SharePoint installed I have tested this with
```
System.IO.StreamReader.Dispose
```
but I am guessing that this should also work for SPContext.Current.Web. Drop a note on this.