ArgumentException: Invalid Field Name (PublishingImages)

Feb 7, 2011 at 5:33 PM

I downloaded the 2.0 stable WSP for SharePoint 2010, installed and deployed it, then activated the solution in my site collection.  I can add the web part to a test page and configure it, but when I point it to my Publishing Images library (created by the Publishing site template in SP2010) and save the web part changes, I get the following error rendered where the web part should be:

System.ArgumentException: Invalid field name. {9da97a8a-1da5-4a77-98d3-4bc10456e700}  /PublishingImages
at Microsoft.SharePoint.SPFieldCollection.GetFieldById(Guid fieldId, Boolean bThrowException)
at Microsoft.SharePoint.SPListItem.get_Item(Guid fieldId)
at SectorPoint.Products.AdRotator.AdRotatorWebPart.GetRandomImage()
at SectorPoint.Products.AdRotator.AdRotatorWebPart.CreateChildControls()

I browsed through the source code here on CodePlex, but I am not sure what could be causing this issue.  Is this web part setup to only use the Advertisement List template that ships with it, or can I use any Image library, such as the Publishing Images library that I already have on my site?

Appreciate any help on this.  Thanks!


Feb 7, 2011 at 6:35 PM

ok, so I've been doing some playing with this, and found that this web part doesn't behave/play well with the OOB Publishing Images document library, mainly because it doesn't have the columns that the web part expects it to have (e.g. Url).

I added a new Advertisement Library from this solutions list template, which creates a new Picture Library with the correct columns and pointed the webpart to that, and it seemed to work after that.

Here's some things I would like to suggest that might be up for grabs for the next release of this web part:

  • allow user to specify the columns used for Url/Hyperlink, etc, instead of hardcoding in web part
  • allow use of folders within the picture library - currently if you append the "/foldername" to the library name, it thinks the library is a subWeb and it throws an exception (maybe use a different popup UI for selecting the library)
  • when no images are available in library, the call to GetRandomImage() throws a NullReferenceException.  Perhaps we could handle this gracefully and display a user-friendly message such as "no images available", or even make this configurable from the web part editor.


Thiago Silva