Monday, January 25, 2010

Why use SharePoint 2010 Sandboxed Solutions?

Title: Why use SharePoint 2010 Sandboxed Solutions?

Details: Below are few thoughts on why to use Sandboxed Solutions
  • Isolation
    • Deployed to the database ( no files within the SBS will touch file system ).
    • Runs under special process, SPUCWorkerProcess.exe
    • Assign Resource Points
    • Doesn’t effect other Site Collections
  • No waiting for farm admins to deploy your solutions
  • Farm admins don’t need to worry about bad solutions any more
  • Runs on partial trust
  • Can be monitored
  • Can be validated

Tuesday, January 19, 2010

Query multiple lists across sites in a web site collection

Title: Query multiple lists across sites in a web site collection

Details: SPSiteDataQuery Class - This is one of the very intresting and wonderful classes available in SharePoint to retreive information from list across sites in the same web site collections. How many of you have tried the roll up ( not including the CQWP ) by coding? Look at the below code and see the simplicity of it. Simply build the SPSiteDataQuery ( query ) to the GetSiteData Method and get DataTable in return. One important thing to notice is that, it is not supported in SharePoint 2010 Sandboxed Solutions.

Code:

void UsingSPSiteDataQuery(SPWeb web)
{
   SPSiteDataQuery query = new SPSiteDataQuery();
            
   query.Lists = "";
   query.ViewFields = "";
   query.Webs = "";

   web.GetSiteData(query);
}

Monday, January 18, 2010

SharePoint 2010 Sandboxed Solutions Solution Validator ( SPSolutionValidator )

Title: Sandboxed Solutions Solution Validator ( SPSolutionValidator )

Details: Now that you already know how to create a Sandboxed Solution, in a typical scenario Farm Admins need some one or some mechanism to evaluate or validate the solutions developed using Sandboxed solutions by the developers. Here is the example of how and what you need to inherit and extend the ootb available classes to write your own.

Code: First, here are the namespaces required

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;

using System.Runtime.InteropServices;
using System.Collections.ObjectModel;

using Microsoft.SharePoint.UserCode; // Under > C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\UserCode\assemblies\

You then need a class that inherits from SPSolutionValidator and overrides couple of its methods as show below. Remmember that this code is going to fire for every other solution thats is added to the solution gallery on a Site Collection.
namespace AltsisSolutionValidator
{
    [Guid("481823F5-75A7-4EF8-8A4B-11C4D52D1014")]
    public class SolutionValidator : SPSolutionValidator
    {
        private const string strValidatorName = "Altsis Validator Name";
        
        public SolutionValidator()
        { 
        
        }

        public SolutionValidator(SPUserCodeService userCodeService)  : base(strValidatorName, userCodeService)
        {
            this.Signature = 1977;
        }

        public override void ValidateAssembly(SPSolutionValidationProperties properties, SPSolutionFile assembly)
        {
            base.ValidateAssembly(properties, assembly);
            properties.Valid = true;
        }

        public override void ValidateSolution(SPSolutionValidationProperties properties)
        {
            base.ValidateSolution(properties);
            ReadOnlyCollection files = properties.Files;

            // Write your validations etc here- extend it as much as you can         
            
            properties.ValidationErrorMessage = " Solution Suceess / Failed ";
         }
    }
}

Alright, now you need a feature to deploy this to Farm Level.
namespace AltsisSolutionValidator.Features.AltsisSolutionValidatorFeature
{
    /// 
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    /// 
    /// 
    /// The GUID attached to this class may be used during packaging and should not be modified.
    /// 

    [Guid("2a4d3a6b-ab9c-4008-9408-26dd4cd1f6d8")]
    public class AltsisSolutionValidatorFeatureEventReceiver : SPFeatureReceiver
    {
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPUserCodeService.Local.SolutionValidators.Add(new SolutionValidator(SPUserCodeService.Local));
        }


        // Uncomment the method below to handle the event raised before a feature is deactivated.

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPUserCodeService.Local.SolutionValidators.Remove(new Guid("481823F5-75A7-4EF8-8A4B-11C4D52D1014"));
        }


        // Uncomment the method below to handle the event raised after a feature has been installed.

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
        }


        // Uncomment the method below to handle the event raised before a feature is uninstalled.

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
        }

        // Uncomment the method below to handle the event raised when a feature is upgrading.

        public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary parameters)
        {
        }
    }
}

Here is my codeplex project template that you can download
http://spsolutionvalidator.codeplex.com/

Thats it. Fire away and see the results for yourselves.

Sunday, January 17, 2010

Error occurred in deployment step 'Retract Solution': Cannot start service SPUserCodeV4 on computer

Title: SharePoint 2010 Error occurred in deployment step 'Retract Solution': Cannot start service SPUserCodeV4 on computer

Details: Building Sandboxed Solutions on SharePoint 2010 using Visual Studio 2010 Beta and encountered the error? Then make sure that the service Microsoft SharePoint Foundation User Code Service ( CA > System Settings > Services on Server ) is Started.


Friday, January 15, 2010

System Center Operations Manager Management Released

Title: System Center Operations Manager Management Packs for SharePoint Server 2010 Beta and SharePoint Foundation 2010 beta

Details: ( from MSDN SharePoint blog post as is ) Management Packs allow users to monitor SharePoint 2010 with System Center Operations Manager. SharePoint Foundation Management Pack and SharePoint Server 2010 Management Pack enables monitoring of SharePoint Foundation 2010, SharePoint Server 2010, Search Server 2010 (These is separate management pack for FAST search), Project Server 2010 and Office Web Apps. Once management pack is imported to System Center console, based on console configuration it automatically discovers what SharePoint bits or servers are installed in the environment that is being monitored and start monitoring those components.

These 2010 management packs will be released to System Center Operations manager catalog and will also be released to web along with SharePoint 2010 RTM.

more details at http://tinyurl.com/y88dmp9

Books for Microsoft System Center Operations and Configuration Manager 2007 R2

Wednesday, January 6, 2010

Speaking at SharePoint Saturday NYC on Jan 30th 2010

Title: Speaking at SharePoint Saturday NYC on Jan 30th 2010

Topic: SharePoint 2010 Sandboxed Solutions

Register: Register here

Link: Other details here

Tuesday, January 5, 2010

ASP.NET to SharePoint Migration

Title: ASP.NET to SharePoint Migration

Details: Added a start up template project to codeplex.

Link: http://aspnet2sp.codeplex.com/

Microsoft Resource File To COFF Object Conversion Utility has stopped working

Title: Error: Visual C# Command Line Compiler has stopped working or Microsoft Resource File To COFF Object Conversion Utility has stopped working

Details: Have you experienced either one of the above errors when you are installing MOSS 2007 on Windows Vista or Windows 7 ??

Solution: Here is the solution for the above error.

Visual C# Command Line Compiler has stopped working

Title: Error: Visual C# Command Line Compiler has stopped working or Microsoft Resource File To COFF Object Conversion Utility has stopped working

Details: Have you experienced either one of the above errors when you are installing MOSS 2007 on Windows Vista or Windows 7 ??

Solution: Here is the solution for the above error.