Where is my facility located?

I have a strange problem: I use SPContext.Current.Web on the .aspx page, but in the end I get "Attempting to use an SPWeb object that has been closed or deleted and is no longer valid." error message.

From what I see, SPContext.Current.Web is Disposed by someone , but I have no idea where . I'm just curious: with Visual Studio 2005 Debugger, I can somehow see where / who posted the object? Since I do not create or use source code, setting breakpoints is a problem.

What would be a good approach to find out who disposes of this object, where, without accidentally commenting out lines?

(Note: The issue has been resolved, but the issue itself also applies outside of Sharepoint)

+3
source share
3 answers

Check if this helps:

  • Add a new breakpoint using Debug> New breakpoint> Break in function ... (Ctrl + B) .
  • Type Microsoft.SharePoint.SPWeb.Dispose in the function edit box.
  • Turn off the dialog box saying that Intellisense could not find the specified location.
  • Run under the debugger.
  • When the breakpoint hits, you can see on the call stack that the Dispose method has been called. I hope that at some points in time, the breakpoint falls into one stack frame in the source code.

If a dialog box appears informing you that the source code is missing for the current location when the breakpoint is deleted, release it.


.. SharePoint, System.IO.StreamReader.Dispose, , SPContext.Current.Web. .

+6

, SPWeb Context . , .

using (SPWeb myWeb = SPContext.Current.Web)
{
   // do something
}

SPContext , .

0

You should read the following: http://msdn.microsoft.com/en-us/library/aa973248.aspx

Be fast: you have to use all your SPWeb and SPSite using

using(SPWeb web = ...)
{
    ....
}

or

SPWeb web = ...
...
web.Dispose()
-1
source

Source: https://habr.com/ru/post/1698256/


All Articles