Pre-register for SharePoint 2010 beta

30 10 2009

logo

In case you haven’t seen this link floating around the web or on twitter yet then here it is:

http://sharepoint2010.microsoft.com/try-it/Pages/Trial.aspx

Simply head over the site and register, you will then be notified as soon as the public beta of SharePoint 2010 becomes available in November 🙂





SPListitem.File.Versions – System.Argument.Exception

28 10 2009

I was writing some code yesterday to loop through the list items in a SharePoint list and then loop through each version of the SPListItem’s underlying file.

Here is the code I was using –

using (SPSite site = new SPSite("http://theserver/"))
           {
               using (SPWeb web = site.OpenWeb())
               {
                   SPList list = web.Lists["The List"];
                   SPView view = list.Views[new Guid("D9E7BDDC-4C77-4386-BA0E-A786D58EE199")];

                   SPListItemCollection itemCol = list.GetItems(view);

                   foreach (SPListItem item in itemCol)
                   {
                       foreach (SPFileVersion version in item.File.Versions)
                       {
                           string url = version.Url;
                       }

                   }
               }
           }

When the code hit the ‘item.File.Versions’ collection it threw a System.Argument.Exception. This really stumped me and I couldn’t figure out at all while the collection was throwing this exception.

After a lot of researching I found this blog post –

http://www.mtelligent.com/journal/2007/10/17/the-insanity-of-getting-versions-of-a-multilinetext-box-set-.html

In this post, David talks about getting the same exception when he is trying to access the list item’s file versions. If you scroll down and look at the comments you you will see that this only seems to be a problem if you are getting the SPListItem as the result of an SPQuery (in my case the spquery is actually an SPView).

This is most likely because getting the item using an SPQuery returns the list item with a minimum amount of data, therefore the versions are not accessible.

The solution here is to create another instance of the SPListItem by using the GetItemById() method which will return all the properties for the list item. This way the SPListItem.File.Versions collection will be accessible and we can iterate through it.

See the correct code –

using (SPSite site = new SPSite("http://theserver/"))
           {
               using (SPWeb web = site.OpenWeb())
               {
                   SPList list = web.Lists["The List"];
                   SPView view = list.Views[new Guid("D9E7BDDC-4C77-4386-BA0E-A786D58EE199")];

                   SPListItemCollection itemCol = list.GetItems(view);

                   foreach (SPListItem item in itemCol)
                   {

//Get a reference to the item again by the ID

SPListItem theItem = list.GetItemById(item.ID);

//The versions collection should now be populated (if versions are available) and no exception should be thrown

                       foreach (SPFileVersion version in theItem.File.Versions)
                       {
                           string url = version.Url;
                       }

                   }
               }
           }

Hope this helps someone! 🙂





Copying files to the 12 Hive with VSEWSS Extensions 1.3

26 10 2009

This had me stumped for a while earlier, I had created a Web Part project and wanted to include an image to be deployed to the TEMPLATE\IMAGES directory of the 12 hive.

Originally I added a module to the project but this would then copy the image to a folder in the actual site itself which I didn’t want.

The solution is to use a ‘Template’ –

Right click on the project in Visual Studio and select Add > New Item

Add new template to the project

Select a ‘Template’ and give it a name, this will add a folder in your solution called ‘Templates’ with a text file inside that has the name you gave above.

You can then add the 12 hive TEMPLATES folder structure under here and any files will be copied to the 12 hive when the wsp solution package is installed.

Templates folder within solution

Hope this helps!





SPBuiltInFieldId – Very useful

22 10 2009

If you ever need to get the GUID of a built in SharePoint field such as ‘IssueStatus’ (from the standard ‘Issue Tracking’ list) for example then you can use the SPBuiltInFieldId class.

This class contains a number of GUID objects for each type of built in SharePoint field.

To use it simply use the following code:

Guid issueStatus = SPBuiltInFieldId.IssueStatus;

I found this very useful, hope it helps some of you!





SharePoint 2010 official blog post by Jeff Teper

19 10 2009

Just spotted this on twitter, this blog post by Jeff Teper –

http://blogs.msdn.com/sharepoint/archive/2009/10/19/sharepoint-2010.aspx

is a must read for SharePoint 2010. It discloses a lot of the new features present in the new product with a few screenshots too.

I hope you all enjoyed the keynotes, I wasn’t able to go to SPC09 but the streaming of the keynotes worked well.

Enjoy 🙂





SharePoint – The Trial Period for this product has expired error

16 10 2009

I had this error message today when trying to create a report center site. After looking through the SharePoint logs I found the following lines:

Feature receiver assembly ‘Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’, class ‘Microsoft.SharePoint.Publishing.PublishingFeatureHandler’, method ‘FeatureActivated’ for feature ’22a9ef51-737b-4ff2-9346-694633fe4416′ threw an exception: Microsoft.SharePoint.SPException: The trial period for this product has expired.     at Microsoft.SharePoint.Publishing.CmsSecurityUtilities.EnsureEvaluationNotExpired()     at Microsoft.SharePoint.Publishing.PublishingFeatureHandler.FeatureActivated(SPFeatureReceiverProperties receiverProperties)     at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce) 

Feature Activation: Threw an exception, attempting to roll back.  Feature ‘Publishing’ (ID: ’22a9ef51-737b-4ff2-9346-694633fe4416′).  Exception: Microsoft.SharePoint.SPException: The trial period for this product has expired.     at Microsoft.SharePoint.Publishing.CmsSecurityUtilities.EnsureEvaluationNotExpired()     at Microsoft.SharePoint.Publishing.PublishingFeatureHandler.FeatureActivated(SPFeatureReceiverProperties receiverProperties)     at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce)     at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce) 

After some googling around I find the following blog post – http://blog.thekid.me.uk/archive/2007/02/05/activating-office-sharepoint-server-publishing-infrastructure-access-denied.aspx.

Changing the application pool account worked and the site was created, although I did have a ‘File not Found’ error first because I had forgotten to enable the ‘Office SharePoint Server Enterprise Site Collection features‘ feature in the top level site collection.

Hope this helps!





VseWSS 1.3 CTP March 09 – Still Buggy

15 10 2009
I’ve been developing a web part today and thought I would try the VseWSS extensions to see if they would get the job done quicker, I normally just create the Visual Studio solution myself and use WSPBuilder (http://www.codeplex.com/wspbuilder) to deploy it.

After I had built my web part I clicked to debug and was presented with the following error:

clip_image002_2

To get past this error I used the following two blog posts:

http://blogs.msdn.com/steve_fox/archive/2009/03/18/vsewss-1-3-post-install-configuration.aspx

http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/02/05/vsewss-1-3-ctp-feedback-and-feature-requests.aspx

It seems that the error is because the account running the application pool for VseWSS web application in IIS does not have the correct permissions. I was on a domain controller so simply gave the account domain admin permissions. This however did not fix the error and I ended up giving the account full control to the folder itself!

When I tried to deploy again I did not get the above error but now a different one (See screenshot below)! I cannot find any more details on this error and the folders specified in the error message do not even exist.  I think im going to go back to using WSPBuilder from now on as it seems the VseWSS extensions are still quite buggy.

Untitled

If anyone has any more details on the above error and how to fix it then please let me know 🙂