SPWeb.Fields.ContainsField(string fieldName) Error after Regional Settings Changed RRS feed

  • Question

  • Hi,
    We have a Site Column called "Venue Location" and have some code to check if it exists.
    This code has been running fine for about  1yr. 

    Here is the code (Note: 'web' is an SPWeb object):

    if (!web.Fields.ContainsField(fieldName))
                    // Do something

    The error we get when web.Fields.ContainsField(fieldName) is called is:

    [5332] Msg(Error Message(Thread was being aborted.) 
    [5332] StackTrace(   at Microsoft.SharePoint.SPFile.get_Exists()
    [5332]    at Microsoft.SharePoint.SPWeb.GetFieldLocalizations(CultureInfo cultureInfo)
    [5332]    at Microsoft.SharePoint.SPWeb.get_FieldLocalizations()
    [5332]    at Microsoft.SharePoint.SPFieldCollection.FetchFieldsFromWeb()
    [5332]    at Microsoft.SharePoint.SPFieldCollection.EnsureFieldsSafeArray(Boolean bGetFullXML)
    [5332]    at Microsoft.SharePoint.SPFieldCollection.get_DisplayNameDict()
    [5332]    at Microsoft.SharePoint.SPFieldCollection.ContainsField(String fieldName)

    The Changes We Made:
    - We then changed the regional settings of the site collection from US to South Africa and reset all the subsites to run on South African Regional Settings settings as well.

    We have set these changes back to what they were originally but the error persists.
    I'm stumped as to what it could be. I suspect it might have something to do with our regional settings changing.  However these have been reset and we're still getting the error.

    This error only occurs when we are hitting the site anonymously.  When logged in it works fine.

    Any thoughts on how to fix this?
    Wednesday, September 30, 2009 2:18 PM


  • If you look at the reflected code of SPWeb.GetFieldLocalizations you will see the following:

     SPFile file = this.Site.RootWeb.GetFile("_fields/resources/_fields." + cultureInfo.Name + ".resx");

    It appears that the IUSR_OURSERVERACCOUNT does not have permission to this resource file when loading the new regional settings resource. SharePoint will throw a "ThreadAbortExcepton" when there is an Access Denied error. You may want to set the SPSite.CatchAccessDeniedException = false before executing the above code and catch the exception yourself then make sure to set it back. This may fix the problem or/also make sure the IUSR_xxx account has read priviliges to the RootWeb.

    Sunday, October 4, 2009 2:50 AM