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
Hello, I read again the code and I added the Company field… and eventually, I can deploy my first SharePoint project.
Thank you all!
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.
Hello,, I´ve updated the UrlSite to the correct value for the application web.
Now I get this error:
Error 1 Error in deployment step ‘Activate Features’: Could not find field named “Company”.
0 0 CreateContentType
Regards,
Maria
In your farm – what is the URL of your web app and site collection? You should use that url in the solution you are making to deploy it to….
In the VS Project this is a setting…. Highlight the project you are working on within the Solution Explorer and update the SiteURL property to reflect the local site you would like to use.
Hello all,
I´ve done several changes.
Now I´m deploying the solution with a user granted as “db_owner” in all SharePoint databases.
I cant check the “Feature scope”… I dont know where to see the scope of the Feature (right button, properties???)
At this moment, I can generate the solution, but when I try the deploy, I get the error:
Error 1 Error en el paso de implementación ‘Reciclar grupo de aplicaciones de IIS’: No se puede conectar con el sitio de SharePoint: http://localhost/SampleWebSite/. Asegúrese de que la dirección URL especificada es válida y de que el sitio de SharePoint se está ejecutando en el equipo local. Si movió este proyecto a un nuevo equipo o si la dirección URL o el sitio de SharePoint han cambiado desde que creó el proyecto, actualice la propiedad URL del sitio del proyecto. 0 0 CreateContentType
Translate to English:
Error 1 Error in deployment step ‘Recycle IIS Application Pool’: Can not connect to the SharePoint site: http://localhost/SampleWebSite/. Ensure that the specified URL is valid, that the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL or the SharePoint site has changed since you created the project, update the Site URL property of the project. 0 0 CreateContentType
I have the solution in the same machine with the SQL Server databases. But I would like to deploy the solution here, but I need to implement the package in other diferent server.
Thank you for your patient!
María