title: BadEnumeration while iterating over sharepoint list fields
body: <p>I'm trying to insert a bunch of data into a SharePoint list.  The List is a custom list based on the <code>Item</code> content type with a couple of custom columns, <code>Contact</code> and <code>Code</code>, where code is a custom field type based on <code>SPFieldText</code>.</p>
  
  <p>I am exploring the list using PowerShell 2.0, and enumerating the fields of the list (or any given list item) causes an exception as follows:</p>
  
  <pre><code>PS C:\&gt; $list.Fields
  
  # output of a few fields
  
  An error occurred while enumerating through a collection: Exception has been thrown by the target of an i
  nvocation..
  At line:1 char:7
  + $list. &lt;&lt;&lt;&lt; Fields
      + CategoryInfo          : InvalidOperation: (Microsoft.Share...on+SPEnumerator:SPEnumerator) [], Run 
     timeException
      + FullyQualifiedErrorId : BadEnumeration
  </code></pre>
  
  <p>I don't really get why this is the case - nothing on the site seems to be broken, and SharePoint Manager is able to enumerate all the fields and list items without a problem.  Further, when I try to grab a single list item and inspect its fields, I get null from my custom field:</p>
  
  <pre><code>PS C:\&gt; $list.Items[0]["Contact"]
  2;#Collins, Ben
  
  _______________________________________________________________________________________
  PS C:\&gt; $list.Items[0]["Code"]
  
  _______________________________________________________________________________________
  PS C:\&gt; $list.Items[0]["Code"] -eq $null
  True
  </code></pre>
  
  <p>The "Code" field in the list doesn't actually have a null value, so I'm at a bit of a loss.  Anyone know what might be going on?</p>