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
Hi Maria,Please check that you are Site collection Administrator?
Hi maria,
There may be few issues and have different solutions as follows:
1- Because of feature Scope.
For this I have attached one cs file. just add in your solution and in featureActivated use as follows:
Replace
using (SPWeb spWeb = (SPWeb)properties.Feature.Parent)
with
SPWeb spWeb = properties.GetWeb();
Hopefully, This will resolve your issues.
If not then,
2- The above error may be because you don’t have access rights to you content database.
For this, you need to
Connect to your database server with DB Administrator credentials or as a user having DB Admin permissions.
Grant “db_owner” rights on following databases:
a- SharePoint_Config (Sharpoint config Db)
b- SharePoint_AdminContent_*******-****-****-*****-******* (Admin Content Db).
c- All databases of your web applications where you want to deploy your solution By default starts with WSS_Content_).
Once you are done with permissions, try deploying your solution package
Hi Maria
Please check the feature scope or try to change the target site URL to see if it works. From memory the second error related to server not being available is due to access issues/site URL not being right.
What scope is you feature = (WebApplication, Site, or Web) ?
My guess is that maybe your feature.Parent is not what you are expecting ?