sharepoint - add custom column to list via object model
I'm having trouble figuring out how to add a custom column type to a list with the object model.

SPFieldCollection.Add() has a parameter SPFieldType, but that must be one of the enumerated values in the Microsoft.SharePoint.SPFieldType enumeration, thus it cannot be used to create columns of a custom type.

I next attempted using SPFieldCollection.CreateNewField() but when I call SPField.Update() on the returned value I get an exception: "ArgumentException was unhandled. Value does not fall within the expected range.".

I see a reference to SPFieldCollection.AddFieldAsXml() here: http://stackoverflow.com/questions/277930/how-do-i-add-custom-column-to-existing-wss-list-template/278921#278921 but there's hardly any info and I'm not sure that's the right track to take.

UPDATE: I found a post on AddFieldAsXml: http://weblogs.asp.net/bsimser/archive/2005/07/21/420147.aspx and it turns out it's very easy and worked well for me.  Posting anyway in hopes it will help someone else.
sharepoint - add custom column to list via object model
===

I'm having trouble figuring out how to add a custom column type to a list with the object model.

SPFieldCollection.Add() has a parameter SPFieldType, but that must be one of the enumerated values in the Microsoft.SharePoint.SPFieldType enumeration, thus it cannot be used to create columns of a custom type.

I next attempted using SPFieldCollection.CreateNewField() but when I call SPField.Update() on the returned value I get an exception: "ArgumentException was unhandled. Value does not fall within the expected range.".

I see a reference to SPFieldCollection.AddFieldAsXml() here: http://stackoverflow.com/questions/277930/how-do-i-add-custom-column-to-existing-wss-list-template/278921#278921 but there's hardly any info and I'm not sure that's the right track to take.

UPDATE: I found a post on AddFieldAsXml: http://weblogs.asp.net/bsimser/archive/2005/07/21/420147.aspx and it turns out it's very easy and worked well for me.  Posting anyway in hopes it will help someone else.