Hello,
I´m trying next example
http://msdn.microsoft.com/en-gb/library/ff630942.aspx
but I have the error:
‘Microsoft.SharePoint.SPContentTypeCollection’ no contiene una definición de ‘Cast’ ni se encontró ningún método de extensión ‘Cast’ que acepte un primer argumento de tipo ‘Microsoft.SharePoint.SPContentTypeCollection’ (¿falta una directiva de uso o una referencia de ensamblado?
With Google Translate ;
‘Microsoft.SharePoint.SPContentTypeCollection’ does not contain a definition for ‘Cast’ and found no extension method ‘Cast’ accepting a first argument of type ‘Microsoft.SharePoint.SPContentTypeCollection’ (are you missing a using directive or reference assembled?
The problem is in the line:
SPField newField = spWeb.Fields .Cast<SPField>() .FirstOrDefault(f => f.StaticName == “Team Project”);
Some idea?
Regards,
María
Well, there is no fields called “Company”.
I would recommend to review/reengineed the code to be able to run and test this code inside VS unit test or console application projects. Ones code is ready, we might consider to wrapping it within feature handler.
Also, consider a proper exception handling (to know what’s going on), a proper class decomposition (it might be not a good thing to put all the business logic onside feature receiver) and testability (ability to run/test the code under console app or unit test). It would help you avoid time wasting and make sure everything works well.
Finally, consider the following post and code snippets as a good start – Go PRO – Several suggestions to implement custom features in SharePoint solutions.
Let me know if there is anything else I may help you with.