Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've got an event receiver that fails, seemingly inconsistently. I've checked the ULS logs and I can see the 90hv Detected use of SPRequest for previously closed SPWeb object. Please close SPWeb objects when you are done with all objects obtained from them, but not before exception raised.

I've got two questions related to this:

Is this an exception that could explain the inconsistent way in which the event receiver works and sometimes doesn't work? I've debugged the code and functionally it's exactly as I'd expect. i.e. Does SharePoint manage the disposal of the object in question sometimes but sometimes it won't depending on system resource etc.?

Is this an exception that could break the code? Or is it just a warning?

EDIT:

It's worth pointing out that my code doesn't explicitly dispose of an object it attempts to reference - but it does without doubt have discrepancies with the way in which I don't dispose of objects I should be disposing of (no doubt memory leak issues) and I'm just looking for confirmation that given this scenario - the behaviour I'm seeing is as you'd expect. Either way, my code is under development now to correct it - just need help with diagnosis.

share|improve this question

1 Answer 1

if you use SPList object outside of SPWeb object. then it generate error which you face.

for eg.

SPList splist = GetListBySite(siteurl,listname);
private void GetListBySite(string siteurl, string listname)
{
   using(SPSite spsite=new SPSite(siteurl))
   {
     using(SPWeb spweb=spsite.OpenWeb())
     {
        return spweb.Lists[listname];
     }
   }
}
share|improve this answer
    
The problem is that I can't appear to find any code that would imply this sort of error, and it's not consistent. So what I'm proposing is that I've just not disposed of something properly and as a result the SharePoint memory management system (however it works) is 'manually' disposing of it at a time when I need it - occasionally. +1, thanks a lot for your answer. –  DeeMac Jan 14 '13 at 8:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.