Wednesday 9 June 2010

SPMetal not generating correctly on lists with only a Title column

Problem: I have 7 custom lists in my SharePoint 2010 site. I run SPMetal against these lists and only 5 lists as available in LINQ.

Initial Hypothesis: SPMetal is broken followed by alot of frustration which eventually I worked out that a custom list must have additional columns to Show up in SPMetal.

Resolution: Create an optional column if you only have the "Title" column in a list that you wish to use Linq to SharePoint on.

Tuesday 8 June 2010

Developer SharePoint Machine Prep

BgInfo - Automatically display local computer information on the desktop's background, such as the computer name, IP address, ect
Disable ShutDown Event Tracker - Stop the comment box on Shut down of your developer machine.
CKS - Community Kit for SharePoint: Development Tools Edition by Matt Smith and others. Invaluable if not just for deployment of code.
.NET reflector - Explore compiled .NET assemblies
SharePoint Dispose Checker Tool
SharePoint Manger
U2U - CAML builder tool - Still a great tool and works with SP2010
WireShark
SharePoint Designer (SPD) 2010
Visual Studio 2010 (Professional version is the lowest edition but any version will work)
FireFox with Firebug (like the IE developer toolbar, good developer tools e.g. css), collazilla (colour picker for firefox), Firequery (jQuery addin), FiddlerHook (integrate Fiddler) & YSlow (Page performance and optimisation)
Fiddler
IE Developer Toolbar part of IE 8
Update 29/08/2010 - Visual Studio 2010 SharePoint Power Tools - Useful if you are using Sandboxes, adds 2 functions: Sandbox visual web parts & Sandboxed compilation.  Also note CKS has remove there sandboxed template in version CKSDev 1.1 release 1 August 2010.  Update 23/06/2012 - CKSDev is at version 2.4
Accessibility: http://www.cynthiasays.com/ &
Update 20/09/2010 - Also add Visual Studio 2010 Sharepoint Power Tools, it has sandboxed solutions and sandboxed visual web parts has been removed from the CKSDev project, so also get the latest CKSdev code.
Update 20/09/2010 - SPTraceView on codeplex is worth installing.
Update 26/11/2010 - Enable wifi on Windows 2008 R2
Update 24/06/2011 - Smtp4Dev is a useful codeplex project for collecting email sent from the dev machine.
Update 24/06/2011 - Office 2010 Plus has all the office applications and includes InfoPath.
Update 24/06/2011 - Visual Studio 2010 SP1 was realease in May 2011 and should be installed.
Update 24/06/2011 - Unit Testing nUnit, TestDrive.NET & TypeMoch or Rhino Mochs.
Add VS cmd prompt to VS using External Tools:  %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
Update 08/01/2013 - Create Shortcuts on the desktop using Powershell (14 hive folder and  hosts.exe) download
Update 09/01/2013 - Ps to add hosts entries.
Update 13/02/2014 - Process Explorer (Usefule if a machine has high memory, CPU or IO issues)
SoapUI if you are working with web Services.

Moving content between environments

There are some good options for moving content and sites in SharePoint. I have seen to many people write custom migration tools and I strongly urge you to look at Chris O'Brien's Content Deployment Wizard and Metalogix's products before writing a custom tool.

Chris O'Brien has updated his Content Deployment Wizard for SP 2010 - for those of you that don't know the tool from MOSS it's a pretty useful tool for moving content between your SharePoint sites. Take alook at it on CodePlex.
http://spdeploymentwizard.codeplex.com/

Metalogix offer some really good tools around migrating content. The licencing can work out rather expensive for simple jobs but still far cheaper than writing complex code migration. It is very flexible and on the 2 MOSS projects I used it on I would highly recommend their products.
Metalogix have a wide range of tools for moving data to and from SharePoint including from other CMS & html websites.
http://www.metalogix.net/
You can migrate web sites, MCMS 2002, MOSS, file shares, exchange public folders, google apps, to SharePoint or SharePoint online.  I believe Metalogix works for BPOS via web services and for SP365 will use restful web services (.Svc) via the 3 client object models.

More (MSDN) information on SharePoint Migration using the SharePoint API
http://msdn.microsoft.com/en-us/library/bb249963.aspx
I'm sure there are other good/bad products out there so if you have used any pls add your comments.

Monday 7 June 2010

Using Session State in SharePoint 2010

Problem: I have setup session state but when I try add a custom object (class instance) to me ASP.NET session state (SQL) I get an error "unable to serialize the session state. in 'stateserver' and 'sqlserver' mode asp.net will serialize".
Initial Hypothesis:
I am adding a class to my session state
Client Instance = new Client("Paul", "Male");
HttpContext.Current.Session["ASPNETSession"] = Instance;
The Client class is not marked as Serializable

Resolution:
Mark the "Client" class as [Serializable]
http://dotnetguts.blogspot.com/2009/06/steps-for-session-inproc-mode-to.html

Sunday 6 June 2010

Application Architecture in SharePoint 2010

Problem: I have a client that needs a composite built using 2010. The application is used to manage digital assets for suppliers. Key questions are where to store data and how to access the data.
Hypothesis: Where to store data, previously in MOSS I would of used SQL Server and accessed it via the BDC or custom web parts. In SP 2010 lists have been vastly improved and are now a good option for storing data. The new External Content Type can be used on SQL but goes beyond my requirement.
The key improvements to SharePoint lists are:

  1. Lookup lists are improved and easier to implement;
  2. Query joins and LINQ improve retrieving data;
  3. LINQ gives you strongly typed lists which using the old "Server Object Model" were weakly typed;
  4. LINQ querries are converted to CAML querries and therefore more performant than using the Server object model method and alot cleaner than using CAML to query data;
  5. Formula based validation on fields;
  6. Store level enforcement (MOSS enforce requirements such as null values only at the UI level);
  7. Improved referential integrity between lookup lists.
My choice was between using SQL Server to store the application data and SharePoint lists. SQL tables have the following key advanatages of they are more performant, and are transactionable. The easy of use and adavantages meant that SharePoint lists are the prefered option for storage.
Application for the suppliers and users also has several options however SharePoint provides most of the admin screens. The actual app can be built using application pages or web parts or the method i prefer, the client object model.

Accessing SharePoint Data options to consider are: Client Object Model (Weakly typed), however REST API's are Strongly typed for SP lists only. New in SP2010
Server Object Model (OM) is weakly type lists but offers the most flexibility. The Server OM existed on MOSS but is improved in SP2010. LINQ gives strongly type SP lists that can be read-write (new in SP2010)
Resolution:
Used SP lists to store the digital assets, the ordering data is also stored in SharePoint lists. For speed of development in the prototype I built using application pages using web parts that accessed the lists using LINQ to SharePoint. The final application will be built using the Client OM.

Friday 4 June 2010

BDC is replaced by BCS in SP2010

  • Business Connectivity Services (BCS) is the replacement for Business Data Catalog (BDC) (MOSS 2007). Brings external data into sharePoint. External data source can be SQL, or Web Services, so it is pretty easy to have CRUD Access to databases, ERP or third parties.
  • BCS has read and write support.
  • Both SPD (SharePoint Designer) & VS 2010 have tooling support for entity modeling to connect your line of business application (LOB).

SharePoint 2010 Developer dashboard

Overview: Developer dashboard allows you to see all calls made from a page under the page in the browser. This allows you to identify poorly performing code & bottle necks. You can see the call stack and the time it takes to perform each call.
OOTB the developer dashboard it turned off. Turn it on using an stsadm cmd or powershell cmd.

Developer dashboard can be setup to allow only certain users to view the stats, this means other users don't suffer the additional resource calls but the developer/administrator can view poorly performing code & page statistics.

Stsadm Method:
1.> Open a cmd prompt running as an administrator
2.> go to: c:\program files\common files\microsoft shared\web server extensions\14\bin and
3.> run the following cmd:
stsadm -o setproperty -pn developer-dashboard -pv ondemand
Cmd prompt to turn on the developer dashboard
4.> In the browser click the developer dashboard icon in the top right of the page, as shown below. On the page you can now see the page call information.

Web Services Using the Object Model (Web Serives) Method:
SPWebService cs = SPWebService.ContentService;
cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.On;
cs.DeveloperDashboardSettings.Update();
 
Powershell Method:
$db =[Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
$db.DisplayLevel = 'On';
$db.TraceEnabled = $true;
$db.Update()