Question

I have a timer job, which scans all sites and all webs. When looping through SPWebApplication.Sites, ALL BUT ONE Sites are listed.

this is the code:

  foreach (SPWebApplication app in service.WebApplications)
                {
                    foreach (SPSite site in app.Sites)
                    {
                        // site missing here   
                        foreach (SPWeb web in site.AllWebs)
                        { // stuff here  }
                    }
                }  

All Sites are shown in the central administration. Any idea?

Était-ce utile?

La solution

The problem was a missing web.Dispose() in the inner loop which made the code crash just before the site-collection I was looking for.

As Dispose-Errors can not be caught in catch() it looks like the code was running "normal"

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top