Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SP13 Timer Job error at Site[0] "Specified argument was out of the range of valid values."

$
0
0

Hi, I have a strange issue that my Site collection was installed root such as http://sp13server:7071 and have a SharePointLibrary list. Its been working in SP2010 without any issues more than year. I wanted to run this in 2013 environment and initially deployed WSP then it failed to run the timer job with the same issue. I then upgraded the Time solution to support SharePoint 2013. Build and deployment works successfully. During runtime here is how it throws error during debug (contentDb.Sites[0].RootWeb.Lists)

 

 public override void Execute(Guid targetInstanceId)
 {
      SPWebApplication webapp = this.Parent as SPWebApplication;
      SPContentDatabase contentDb = webapp.ContentDatabases[targetInstanceId];
      SPList DocLib = contentDb.Sites[0].RootWeb.Lists["SharePointLibrary"];  // Error throws here.

      //Alternative I tried below
                using (SPSite site = contentDb.Sites[0])   /Error throws here
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList DocLib = web.Lists["SharePointLibrary"];
                    }
                }

 }

Any advise to change for SP13 is greatly appreciated.

Thanks

Shri


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>