Posts Tagged ‘SharePoint’
Monday, May 24th, 2010



I had to post this quick article as its one of those can’t see the wood for the trees.

I had been trying to do a simple call back to the server to display some information about a list item.

   getStory: function (id) {
    var backLogList = this.lists.getByTitle('BackLog');
        this.itemToGet = backLogList.getItemById(id);
        context.executeQueryAsync(
        Function.createDelegate(this, com.apps.aberdovey.SprintPlanning.getStorySucceeed),
        Function.createDelegate(this, com.apps.aberdovey.SprintPlanning.onFail));
    },
    getStorySucceed: function (sender, args) {
    alert('got it');
    },

The problem was I never got anything to happen.  My onFail() had an alert and I also showed an alert when the call succeeded.   But nothing.

I reverted to IE Dev toolbar where I kept getting the error

‘b’ is null or not an object

after spending time validating my calling code and cursing the lack of good examples on the web for SharePoint 2010 ECMAScript I eventually found it. 

The delegate name for the getStorySucceed was spelt incorrectly!

It is amazing how much time you spend looking for stupid errors when doing JavaScript development.  This one I thought worth posting so that when other search for ‘b’ is null or not an object they will at least have a better idea what’s wrong.

Tuesday, May 4th, 2010



mainlogo

We are proud to announce the world’s first SharePoint Retreat!

The first event is taking place in London on Saturday 10th July. Don’t delay places are filling up fast with a limit of 16 people.

Register for SharePoint Retreat London in London, United Kingdom  on Eventbrite 

The aim of SharePoint Retreat is to help developers practice the fundamentals of software development, but like all things in the SharePoint community we intend to keep this SharePoint focused, so developers practice the fundamentals of SharePoint development

What is SharePoint Retreat?

The idea is not our own, more information can be found about the original Code Retreat at http://www.coderetreat.com/ – we have just given it a SharePoint flavour. 

It has a simple objective:  provide a day-long event that is focused on practicing the fundamentals of SharePoint development.

Why SharePoint Retreat?

We want to bring SharePoint development to the fore, to make developers want to work with SharePoint and to show that doing SharePoint development does not mean you have forego any plans to become a software craftsman.

How does it work?

A group of SharePoint developers – That means you! - gather at the Retreat with laptop in hand ready to code.

  • Problem:  TBC – the problem will be SharePoint related and can vary between Retreats
  • Retreat lasts from 9am until 5pm followed by SharePint
  • Each coding session will last 1 hour
  • Each session coders will pair program

Some rules!

  • code is deleted after each session,  its about learning the techniques and not getting code samples
  • Encourage techniques like TDD where appropriate
  • programming pairs are swapped at each session

on the day

  • 9:00 – 9:30 Intro to the day
  • 9:30 – 10:30 session 1
  • 10:30 – 10:45 retrospective
  • 10:45 – 11 :45 session 2
  • 11:45 – 12:00 retrospective
  • 12:00 – 1:00 Lunch – with brown bag presentations
  • 1:00 – 2:00 session 3
  • 2:00 – 2:15 retrospective
  • 2:15 – 3:15 session 4
  • 3:15 – 3: 30 retrospective
  • 3:30 – 4:30 session 5
  • 4:30 – 5:00 wrap up
  • 5:00 – late ShareFood and SharePint

in the sessions

session 1 and 2

The area of SharePoint may be unfamiliar to some people, others may have done something like it before.  The aim of the first two sessions are to allow people to understand how they are going to approach the problem and what the final solution could look like.  Some pairs may try and implement it, others will spike out ideas and try to solve specific challenges.

At the retrospectives each pair will have a few minutes to discuss what they did and any problems they could not solve.

Lunch

During lunch the coders get to sit back and relax whilst the facilitator demonstrate techniques or ideas in a couple of short brown bag sessions.

session 3, 4 and 5

continue with the problem and looking to refine some of the scenarios and techniques.  The aim is to learn and practice techniques that will improve the knowledge and experience of the coders.  If you don’t complete the problem it’s not an issue – if you complete the problem then look for new challenges or refine the techniques.

After the event

Any gathering of SharePoint people and you are likely to find a SharePint – the facilitator will find a suitable venue for people to unwind, drink beer and SharePint – hopefully more SharePoint people will be in the area so that they can brag about the new found talents.

What Next?

If you can be in London on Saturday 10th July 2010, you’re a SharePoint developer and you fancy spending a day with other like-minded people honing you development skills.   Sign up.

This first event is limited to 16 coders – so be quick.  

If you fail to make the first 16, put your name down on the waiting list.   We do ask that people who have signed up but for whatever reason can’t make it please make the space available to others.

How Much?  – Its Free :)

Best of all this is a community activity,  we are funding this event through sponsorship in order that we can provide the places to coders F.O.C

The sponsors for this inaugural event are

cScape Logo

providing the venue and internet access – and Ben Robb

21apps Inspire Community

providing the food – and Andrew Woodward

Wednesday, April 14th, 2010



If you have been following my blog, twitter feeds and perhaps visited previous sessions I’ve done, then you will know that I am a very big advocate of Unit Testing – and have made it a personal goal to raise awareness and break down the challenges faced in doing this for SharePoint.

This time I am joining forces with the SharePoint Cowboy, Eric Shupps, to show you some of what you should know,  but also we have some exciting demo’s that you won’t want to miss.

If you understand Unit Testing,  want to learn more or just interested to see us battle it out on stage you have to attend:

DD107 – Unit Testing SharePoint

Tuesday 20th April

10:00 am to 11:00 am

Deep Dive 400 Track

Defining a successful unit testing strategy is a key component in the SharePoint software development lifecycle. In this session we will explore the various options for insuring adequate code coverage for custom SharePoint solutions, examine several different methods and tools for creating and executing unit tests, and discover tips and tricks for working with various test frameworks. There will also be a lively discussion regarding the value of implementing methodologies such as Test Driven Development and numerous real-world examples of the benefits unit testing can provide within custom SharePoint solutions

 

clip_image001

Monday, February 22nd, 2010



In this article and screen cast we will discuss the idea behind the CI process and focus on the technical tricks that we need to make in order to get this working for a SharePoint 2010 project using Team City and Subversion.

One of the first things that you will want to do for any development project is setup your Continuous Integrationprocess. The value of having a server automatically monitor your source code repository for changes and validating they work is immense

Its worth mentioning that doing Continuous Integration is not something you will want to leave until later in the project.  Waiting means the solution gets bigger and more complex which in turn make the setup more comples.   My recommendation:  Get this configured early, during Sprint 0  (i.e. before you write any real production code) if at all possible.

The basic CI Process

The diagram below shows the normal process that occurs.  

(1) a developer checks in some code changes to the source code repository.

(2) The CI server monitors the source code repository for any changes

When changes are detected the code is retrieved and the automated build is started.  This build will normally include running Unit, Integration and Build Verification tests.

(3) The success or failure of the automated build is reported back to the Team (including the developer).

In some teams breaking the build means the developer has a forfeit of some sort.  The idea is to encourage team work but also to discourage broken builds.

Continuous Integration 

When the build breaks!

A term I read recently, ‘Stop-the-Line’,  is used in Toyota manufacturing process where any problem results in the production line being stopped until the cause of the problem is found, resolved and ideally prevented from re-occurring.    

This should be the same when a build breaks; the whole Team should stop and help get the build working again.  It is not just a problem for the developer who last checked in – the whole team need the process and need the builds to be working.

Setting Up in Sprint 0

The actual process described above is a little into the development cycle, when the build is in place and when the team are working on production code.   Before this can happen there needs to be a process put in place.  I refer to this initial as getting the strawman solution done.

definition: Strawman

In general, a strawman is an object, document, person, or argument that temporarily stands in for and is intended to be “knocked down” by something more substantial.    

source: Whatis.com

The aim is to take some code, which will be replaced hence the Strawman term through the CI process and get the team build notifications working.   You should aim to prove the successful builds but also what happens when the build fails.  Did the team get notified?  and did they react?

The Strawman Exercise

21apps is a small and geographically dispersed team,  we make extensive use of cloud based services for things like source control as they prove to be cost effective and flexible and our strawman  process tends to follow these steps:

1) Create a repository for the project  (Hosted Subversion)

2) Create the strawman project  (Simple ‘hello world’ web part)

3) Create a simple build script  – small steps mean a successful compile is our objective

4) Create a automated build configuration on our CI server – we use Team City

5) Prove the successful and failed builds

In this post we are focusing on step (4) setting up Team City as our CI server. 

To make this easier I have provided a quick video walkthrough on what we have done for the early builds of Project Aberdovey- the process will be very similar for your SharePoint 2010 solutions.

 

SharePoint 2010 – CI with TeamCity from Andrew Woodward on Vimeo.

 

Video Spotlights

Key areas that are highlighted in the video that you will enable you to build SharePoint 2010 projects in Team City.

If you are using MSBuild ensure you set the MSBuild version to Microsoft.Net Framework 3.5 and x64 run platform.

image

 

Force Team City to use MSBuild 4.0 as this is needed by adding the Environment Variable

Name: MSBuild

Reference Syntax: %env.MSBuild%

Value: %system.DotNetFramework4.0_x86_Path%

image

Monday, February 8th, 2010



Normally I refrain for doing simple reposts of other people blogs,  however having read the post SharePoint’s Sasquatch Memory Leak by Todd Carter I just had to help get the information out to as many people as possible.

We are all being good developers and running SPDisposeCheck regularly on our code to make sure we don’t leak memory,  however for some we still experience spiralling memory leaks that seem untraceable.  until Todd’s post that is.

Rather than hang around here you MUST read it now,  and if your experiencing issues and have SPDisposeCheck’d your application to within an inch of it’s life with no success on controlling memory you will want to implement the workaround as soon as possible.

Big Thanks to Todd find Big Foot :)

Saturday, January 30th, 2010



Firstly what is a SharePoint SPI?

No it’s not another new version, it’s a generic term that is used to describe a SharePoint Project Item within the context of a Visual Studio project.

Visual Studio 2010 has introduced a lot of great SharePoint specific features making it significantly easier to get started with SharePoint development. This post however is not about the tools, it is intended to point out one little bit of the hidden functionality that unfortunately didn’t get completed in time.

The Visual Studio tools hide away so of the configuration options in .spdata files. This is normally great as you can change these via the UI tools and everything works. However I discovered a small issue during a recent refactoring of a project.

When you create a new SharePoint SPI (for example a web part) that needs to add a reference to the assembly it updates the .spdata file with information (as below)


<?xml version="1.0" encoding="utf-8"?>
<ProjectItem Type="Microsoft.VisualStudio.SharePoint.WebPart"
   DefaultFile="MyWebpart.cs"
   SupportedTrustLevels="All"
   SupportedDeploymentScopes="Site"
   xmlns="http://schemas.microsoft.com/VisualStudio/2010/SharePointTools/SharePointProjectItemModel">
  <Files>
    <ProjectItemFile Source="Elements.xml" Target="MyWebpart\" Type="ElementManifest" />
    <ProjectItemFile Source="MyWebpart.webpart" Target="MyWebpart\" Type="ElementFile" />
  </Files>
  <SafeControls>
    <SafeControl Name="MyWebpart"
       Assembly="$SharePoint.Project.AssemblyFullName$"
       Namespace="_21apps.Sample.SPSolution" TypeName="*" IsSafe="true" />
  </SafeControls>
</ProjectItem>

 

In here you will see references to the ProjectItemFiles (.weppart and element manifest) and also an entry for the SafeControls.

If you look closely at the SafeControl entry you will see the Assembly is using a Token

Assembly=”$SharePoint.Project.AssemblyFullName$”

This is great as it allows the SafeControl to pickup the actual assembly name at compile time. The problem comes with the next part of the entry

Namespace=”_21apps.Sample.SPSolution”

As you can see this is not token based, which means that if you later decide to rename you namespace, and this is case sensitive, the SharePoint safe control entry will no longer be valid and you will get an error like the one below when you deploy the solution.

A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe.

For more info on what this actually means have a look at Maurice Prather’s post from back in 2005, the information is still applicable today.

Unfortunately this namespace is unlikely to be made into a Token any time soon. Perhaps one for the community to pickup in the meantime. For now it is case of being aware that you need to correct this manually if you do change your namespace.

Saturday, January 30th, 2010



On Thursday, 28th Jan 2010, I made my way down to the London SUGUK event.  I’ve been supporting the regional events and been unable to get down to London for a number of months.   The number of attendees was amazing – I didn’t count be I guess we have over 150 people and filled the room at Microsoft.

IMG_0019

IMG_0020

I did know quite a few regulars to the event,  but the great news again is the number of new faces.  SharePoint is really growing fast and wide and the need for information and community is growing with it.

IMG_0022 

Big Kudos to Matt for organising the event,  Matt has taken on the responsibilities for the South East and London,  to Ben Robb for doing a SharePoint Designer 2010 session  (although as he points out the whole Application Lifecycle Management is still not baked) and for Steve Smith for – umm not sure what Steve did :)

It was great to see Mike Fitzmaurice there  (this man made SharePoint happen),  and I suspect his presence on the panel was part of the reason the questions and discussion remained in the ITPro and User space.   Myself, Chris O’Brien, Matt Smith and Ben Robb tried hard to put a dev take on any questions where we could.

What I think would go down really well is to take a lead from the Nottingham group and organise focused events,  so we could have a Dev night, Design Night, End User night etc.

I have to apologies (thanks Alex Pearce for tweeting me this when we were in the Pub) – I did not advertise the #SharePint that took place afterwards, It was well attended and with more room than the pub we used to go to but not an ‘official’ #SharePint.

Hope to see you all at an event near you soon.

Sunday, January 10th, 2010



Being mainly focused on development aspects of SharePoint 2010 I haven’t spent as much time as I perhaps should have looking at the new features that have been added to make Administrators lives easier.  Having just upgraded one on my development machines from SharePoint 2010 Foundation to SharePoint 2010 Server for Internet Sites,  which on a single box installation with AD and SQL local went without a hitch, I thought it worth looking at what the Health Analyzer was telling me.

As you can see I have a few issues:

Analyser Summary

Security

The security Issue I can live with and I suspect everyone running the Beta has the same as using full admin accounts is the only way to get SharePoint working fully at this stage.

Performance

This is a dev box, so I am ok with SQL running on the same machine,  interesting that this is the only performance issue reported as the machine is a Hyper-V VM with 4 processors allocated and only 4GB RAM – but it seems to be running fine.

Configuration

3 items here – the second is about Email not configured – which is correct.  And again I have used built in accounts for the service identities as this was a single box install – I may fix these up at some point.

The 3rd item Missing server side dependencies caught my eye,  and I have to say the dialog that was displayed brought a smile to my face.

Analyser

The server was reporting that I had referenced a web part TestJQuery.WebPart1.WebPart1 in two places and that the files to support these web parts were not on the system meaning the user will get an error.

This is awesome!

I know why these are here,  it was a spike test that I had done previously and had obviously forgot to clear it down.  What it does show is that the administrators (and developers on your own environments) can now proactively check for missing DLLs.

This was not one of the features I asked for in SharePoint 2010 – but is one that I am very glad exists. 

Availability

How many times have you been called in to find the logs have maxed out the drive space and SharePoint has crashed?   Here the health analyzer is telling me I may have an issue with space.    I’m ok with this,  I have a 40GB drive with 11GB free – I like to keep the drives around 40GB as I move then to my laptop and boot to VHD and this needs the full drive size as free space in order to boot – so I can let this one go as well.

The only thing left to say this is:

Thank you SharePoint Product Team.

Thursday, December 31st, 2009



I think this was a best practice in SharePoint 2007, but was one that you could get away with.  You have internal and external URLs that will be used to access the same web application.   Internally for historical or vanity reasons this is set as something like http://companyname, externally you provide access, often via a proxy like ISA Server, via https://extranet.companyname.com – and you do SSL termination at the ISA server as well.

You create the web application using the internal name,  get everything setup and then do the following to provide external access

This scenario would work well,  you would cut down on the web.configs to be maintained – assuming you didn’t use features to do this for you, and you would have a slightly lower overhead on the server – which was often needed in the 32bit setups.

Problems in 2010  (and for some in 2007)

With the introduction of the client API, and a few other services, Microsoft is now making use of the WCF for its web services.   These offer lots and lots of advantages,  but have one limitation (at least in 3.5) that makes the above scenario fail. 

You cannot have multiple bindings on any IIS website

If you do set your environment up this way and you are using the client API you will hit problems.  Assuming you have coded you client requests with a fail delegate (like this code snippet)

  1: var lists;
  2: var context;
  3:
  4: function sample() {
  5:     context = new SP.ClientContext.get_current();
  6:
  7:     this.site = context.get_web();
  8:
  9:     context.load(this.site);
 10:
 11:     lists = site.get_lists();
 12:     context.load(lists);
 13:
 14:     context.executeQueryAsync(onPass, onFail);
 15: }
 16:
 17: function onFail(sender, args) {
 18:     alert("Fail:" + args.get_message() + '\n' + args.get_stackTrace());
 19: }
 20:
 21: function onPass(sender, args) {
 22:     onPass(lists.getByTitle('List'));
 23: }

when the async mehtod is called it will fail and the onFail method will show a 500 error.  One of the best things is the logging in 2010 has been improved so a quick look on the server and you should see something like the following in the event log:

Log Name:      Application
Source:        System.ServiceModel 3.0.0.0
Date:          31/12/2009 16:22:06
Event ID:      3
Task Category: WebHost
Level:         Error
Keywords:      Classic
User:          domain\sp-admin
Computer:      computername
Description:
WebHost failed to process a request.
 Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/2389992
 Exception: System.ServiceModel.ServiceActivationException: The service '/_vti_bin/client.svc'
cannot be activated due to an exception during compilation.
The exception message is: This collection already contains an address with scheme http.
There can be at most one address per scheme in this collection.
Parameter name: item. ---> System.ArgumentException:
This collection already contains an address with scheme http.
There can be at most one address per scheme in this collection.
Parameter name: item
   at System.ServiceModel.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item)
   at System.Collections.Generic.SynchronizedCollection`1.Add(T item)
   at System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses)
   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type
serviceType, Uri[] baseAddresses)
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(
String constructorString, Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(
String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(
String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(
String normalizedVirtualPath)
   --- End of inner exception stack trace ---
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(
String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
 Process Name: w3wp
 Process ID: 3924
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="System.ServiceModel 3.0.0.0" />
    <EventID Qualifiers="49154">3</EventID>
    <Level>2</Level>
    <Task>5</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2009-12-31T16:22:06.000000000Z" />
    <EventRecordID>99264</EventRecordID>
    <Channel>Application</Channel>
    <Computer>computername</Computer>
    <Security UserID="S-1-5-21-2646386180-1731120971-3670236442-1114" />
  </System>
  <EventData>
    <Data>System.ServiceModel.ServiceHostingEnvironment+HostingManager/2389992</Data>
    <Data>System.ServiceModel.ServiceActivationException: The service '/_vti_bin/client.svc'
cannot be activated due to an exception during compilation.
The exception message is: This collection already contains an address with scheme http.
There can be at most one address per scheme in this collection.
Parameter name: item. ---&gt; System.ArgumentException:
This collection already contains an address with scheme http.
There can be at most one address per scheme in this collection.
Parameter name: item
   at System.ServiceModel.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item)
   at System.Collections.Generic.SynchronizedCollection`1.Add(T item)
   at System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses)
   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType,
Uri[] baseAddresses)
   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString,
Uri[] baseAddresses)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(
String normalizedVirtualPath)
   --- End of inner exception stack trace ---
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(
String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(
String relativeVirtualPath)</Data>
    <Data>w3wp</Data>
    <Data>3924</Data>
  </EventData>
</Event>

 

The problem, although not obvious from the error message is related to the WCF framework not being able to work with multiple names on the same schema (where schema means HTTP).

Solution

The solution to this is to Extend the web application to another IIS web site.  It will make use of the same application pool but is likely to add a small overhear to the server.  The biggest challenge is to ensure that you get your deployments automated so that SharePoint can keep the web.config’s inline.   And with the introduction of the Sandboxed solution the other issues with artifacts deployed to the 80 (inetpub) folder will likely go away over time.

Thursday, December 31st, 2009



Many people have used the the Content Editor WebPart to provide an easy way to inject some JavaScript into a web page to do things like hide the left navigation or show snowflakes. 

In SharePoint 2010 the good old Content Editor WebPart is still around and even has some nice new features like format as XHTML,  however I discovered one feature that I suspect is more of a bug – or perhaps an undocumented feature :)

Scenario

You have used the content editor web part to put some placeholders on the page,  a couple of DIV tags and the like.   You have another web part (it could be the same one) that does some funky Client API calls to get some information to render in those place holders <  all looking good for a simple no code solution so far.

Now you decide that you want to copy you handy work to another site,  this is just a quick ‘Information Worker’ hack so no need for any Visual Studio or WSPs here.

Edit the page and select the content editor web part,  the one that has has some content dynamically added.   Click on the HTML > Edit HTML Source option and da-dah the dynamic content is included in the source.

Upshot

This could be a great thing if you wanted to get at all of the code,  but I suspect this is not what you expected.  The problem is that if you now make a minor change – say you wanted to add something and click save,  you will hard code whatever values had been added.

I would prefer the Content Editor Web Part source Editor to ONLY show me what I has actually added to it in the web part properties.   I suspect the reason for the bug is likely someone trying to reduce the calls to the server.

Serious Problem

The problem is actually quite serious as you only need to visit the page,  click Edit Page and then Stop Editing for it to update the content.   This really does mean that you will have to stop using the CEWP in this way at least for the Beta.