The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

  • Advertisements

Site Columns Gallery Error

Posted by Clayton James on August 4, 2008

I was receiving this error the other day when trying to access the Site Column Gallery.

Object reference not set to an instance of an object.   at Microsoft.SharePoint.ApplicationPages.FieldListRenderer.Render(HtmlTextWriter output)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) ……..

It turns out that if you create a site column using the object model it capitalises SITES in the url.

The root problem was with the request Url we used to open a SPSite/SPWeb.  It turns out that the request Url you use to construct a SPSite is *case sensitive* to the URL the way it is specified in SharePoint when it comes to creating SPField objects programmatically.  I know that seems a little hard to believe but we ended up driving this bug through PSS and after getting our Content DB demonstrating the problem into MS hands they walked through their code and identified the problem in the code behind mngfield.aspx and a requirement that any fields created via WSS must have been done so through an SPSite/SPWeb with case that exactly matches the target site.

One additional thing we found through this two month adventure researching this bug, you can see the fields in a root site collection via mngfield.aspx *if* you view the Site Column gallery from a sub site of the site collection where mngfield.aspx is returning the Unknown Error/Null reference exception.

Here is how you can determine if the fields you created have the appropriate case-sensitive scope.

1. Create a sub-site under the site collection.

2. From that sub-site, select Site Actions -> Site Settings -> under Galleries -> Site columns

3. The mngfield.aspx page should display, and you will see all site columns from the parent site collection.

Note that the Source column on this page is a hyperlink to the site collection mngfied.aspx.  If you click this link you’ll be taken to the familiar Unknown Error.

4 Look for any site columns that your code added to the site collection.  Pay particular attention to the letter-case of the Source hyperlink Url.  If you’re hitting the same issue we found, you’ll note that the hyperlink Url case does not match the case of the actual site.

Basically there is a line of code in the code behind mngfield.aspx that does a check something along the lines of “field.Scope == web.ServerRelativeUrl”.  The ‘==’ op was a poor choice as it doesn’t handle mixed cases.

Once a Site Column has been created via WSS using a SPWeb instance that was constructed with mis-matched case that column is broken, it cannot be fixed.  You’ll have to delete it and recreate under a SPWeb that was constructed either a) with a request Url of appropriate case or b) the safer option is to construct SPWeb/SPSite instance using their GUID constructor since that forces a Url lookup which will always be accurate.

So to fix this you need to navigate to the fieldedit.aspx page in the layouts directory, pass in the field name and then can you can delete the problematic site column.
e.g.  http://moss/sites/companyxyz/_layouts/fldedit.aspx?field=tt


9 Responses to “Site Columns Gallery Error”

  1. Yorick said


    I am experiencing this exact issue with the default “Office SharePoint Server Enterprise Site Collection Feature”. It creates site columns with capitals in the managed path name, when the managed path is created using lower case names.

    I tried removing all of the Record content type site columns and then reactivating the feature, but it created the removed site columns with the incorrect managed path again.

    Do you have any clue how to solve this?



  2. Joan said

    Your tip saved me after I created an InfoPath form and published two integer fields (that should have been text) to site columns. Neither showed up in the Site Column Gallery. Googling revealed that a few others have had the same issue publishing integer fields. I was able to use the fldedit.aspx?field= to get to the site columns and delete them. I was then able to republish as text columns. Thanks so much! (PS I am not a developer; I do everything via the GUI or what little I know of SharePoint Designer)

  3. I ran into this issue while writing code that adds Site Columns via the web service. For a long time I have been able to delete troublesome columns from sites and lists using the API. There are many things that cause these to fail. But, it’s great to see such a concise and easy to understand explanation of *why*. Thanks a bunch!

  4. Yaron said


    I read your POST and I would like to say Thanks for your help. I also need to ask another question regarding the fldedit.aspx? field=FieldName. I have a problem because the Field I am trying to delete is wrriten in Hebrew and I have no way to know what is it’s English Name. The second Problem is that I do not know why but the Field I think is the Problem was created by an out of the box MOSS workflow that I am using in my doclib. Is it reasonable that the OOTB workflow will mistake while creating site columns ?

    Thanks again for your help.


  5. jriesen said

    The problem you described seems to be exactly our issue and I was really hoping fix-it steps could solve our problem, but so far not so lucky. I can see the site column I want to delete using your steps of viewing the Site Columns from a sub-site, but when I use the …/_layouts/fldedit.aspx?field=Document%20Type I get the following error.

    Value does not fall within the expected range. at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName…

    Any ideas what steps to take next to resolve the issue.

    Let me know if you need more information.

  6. Yaron said

    Hi, I solved the problemm with the last option:
    1. stsadm backup the whole sitecollection (the restore it in test environment to see that it works)
    2. delete the sitecollection
    3. re-create it but this time with small letters only
    4. restore from file with overwrite option

    A few comments:
    1. The problem occured for me while creating workflow with SPD wizard
    2. Every sitecollection from now on will be created with small letters.
    3. I do not know if I would do what I did If I had a lot of data in the site. I deleted it because it was in the development phase.

    Good Luck

  7. Selina said

    Gracias por invitarme a escribir he disdrutado con tu blog no te conocía a partir de hoy.
    Felicidades tienes una web fantástica Gracias por compartir con todos.

  8. Betsey said

    Buenas me ha encantado con tu post no te conocía te empiezo a seguir hoy.
    Mi más sincera enhorabuena tienes un sitio super interesante Gracias por compartir con todos.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: