From: Dan Hayman Sent: Friday, 13 June 2008 12:33 p.m. To: SharePoint Interest Group Subject: SPListItemCollection.count Null reference exception Hi, Does anyone have any idea why I sporadically get a null reference exception on the last line of this code. I can't replicate it reliably, it just happens sometimes. Null reference exception - "Object reference not set to an instance of an object." SPWeb web = _site.RootWeb; SPList List = web.Lists[list]; SPListItemCollection listCollection = List.Items; int i = listCollection.Count; Stack trace: at Microsoft.SharePoint.Library.SPRequest.SetVar(String bstrUrl, String bstrName, String bstrValue) at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() at Microsoft.SharePoint.SPListItemCollection.get_Count() Cheers, Dan Dan Hayman Development and Integration Services INTERGEN: LEVEL 1, 2 FRED THOMAS DRIVE, TAKAPUNA, AUCKLAND, NEW ZEALAND. TEL +64 9 966 3070 FAX +64 9 966 3071 MOB +64 27 697 7148 WWW.INTERGEN.CO.NZ <http://www.intergen.co.nz/> Want me to do something? Send me an action item: www.actionthis.com <http://www.actionthis.com/> Catch the latest on our blog: www.intergen.co.nz/blog <http://www.intergen.co.nz/blog> Be kind to the planet: Do you really need to print this? ________________________________ This electronic message together with any attachments is confidential. If you are not the intended recipient: (i) do not copy, disclose or use the contents in any way (ii) please let us know by return e-mail immediately and then destroy the message. Intergen is not responsible for any changes made to this message and/or any attachments after sending by Intergen. ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com
