0
votes

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?

1
What is the one that is missing? Do you have the correct permissions? What about if you wrap this code in a SPSecurity.RunWithElevatedPrivileges block?Steve B
I wrapped the inner part (after foreach web) into a RunWithElevatedPrivilegues This code is running in a JobDefinition. Should have the needed rightsOle Albers
PLease try to wrap the outer loop in this block. One possible cause is that the app.Sites enumeration has not enough privileges.Steve B
It was something completely different. A Dispose-Isue in the Site-Object that was loaded before :)Ole Albers
Glad you find the solution. Please answer to your own question, in order to mark the question as answered.Steve B

1 Answers

0
votes

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"