Archive for the ‘SharePoint’ Category
Thursday, June 25th, 2009



Following on from my rant response yesterday about the more negative views from the SharePoint community my reading this morning was so much more positive.

Unit Testing Workflows

In my response to a question from Aaron Weiker I said that I would like to see much more guidance and investigation into the way we approach Unit Testing workflows in SharePoint,  so it was great to find Richard Fennell is doing a lot of work in this area.  I have been working with Typemock Isolator, CThru and SilverUnit testing recently (post coming) and was very interested to see that Richard had picked up this whilst looking for a possible solution to the challenges of Unit Testing SharePoint workflows; something I have to confess I had not even considered.

I’m looking forward to seeing where Richard gets with this and also the use of Fit/Fitness, although I’m personally not a big fan of the way tables are used to define the tests.

Integration Testing SharePoint from MSTest

Having been a bit behind with my reviews of the latest Codeplex P&P project I missed the discussion with Francis on how they found a use for Typemock Isolator to do Integration tests.

The code is really very very simple,  many will be glad to hear, and deals with the places where your code makes a call to SPContext.Current or SPFarm.Local.

The simple ideas really are the best ones.

As you can see,  a few small steps for testing but big steps for SharePoint testing and a demonstration that in general the SharePoint community is committed to improving the way solutions are developed.

Tuesday, June 23rd, 2009



Just read a post by Sahil Malik where he gives his reasons for saying

TDD + SharePoint 2007? Well – screw it! Not worth it IMO.

The reason for his statement is that he sees the actual C# code developed as being a very small % of the total SharePoint project and the effort to do this as not worth the return when you consider the project costs overall.

The problem is, like so many people, he is getting TDD mixed up with doing good development.  He dismisses TDD because it is harder to do in SharePoint because of the API.  It’s not TDD that makes it harder,  it being able to isolate the API and design testable code that is harder.

If you listened to the SharePoint Podshow I did with Eric Shupps we were in agreement that what actually mattered was that you developed good quality code,  that you had the processes in place to enable code reviews, unit testing, integration testing, and the like, that all go together to ensure the code you do develop for your SharePoint solutions is Enterprise ready.

I hold my hands up, I do talks on TDD and SharePoint.  I don’t do this because I think that everyone should do this on day one,  I do it because people have used SharePoint as an excuse to not doing quality development.  The comment ‘we can’t do unit testing because we are using SharePoint’ has been common among development teams,  other just don’t do unit testing anyway so it never even cropped up.   So if I can demonstrate the you can go all the way and actually code your solution using a technique like TDD then this argument no longer holds water.

What the question should be

Quality Development and SharePoint, is it worth doing?

And the answer to that is a big Hell Yes!

And if your happen to use TDD to write some of that quality code, then that’s good too.

The key thing to remember is that you need to make a judgement call about the value; in Sahil’s defence he did mention this.  What I can’t take is that he adopts the ’screw it’ stance before he even starts. This to me is a much of a problem as the people at the other end of the spectrum that think you can ONLY code using TDD.

Saturday, June 20th, 2009



Scrum as an agile approach is great, it allows teams to get up to speed quickly with agile and also enable the business to understand what being agile means.  The problem is that people often just do Scrum.  Doing Scrum is not enough,  it is a great place to start and will help you with your projects but your team still need to get the engineering disciplines in place, they still need to work on doing the right thing the right way and with level of quality demanded by the business.

Jack Milunsky posted a nice article that talks about why Measuring Velocity is not enough.

Like burndown charts, velocity is just another metric which the team can use to reach what I believe is the ultimate goal – sustainable throughput. Velocity in my opinion, is not a metric for determining productivity.

What I really liked, and is something that I am going to be covering a lot more over the coming months is the conclusion

.in order to enhance productivity there are many things one can do:

* You have to get the requirements down pat. The best way to do this is to work with the customer to define the user stories and get their intent up-front.
* Ensure you are capturing the acceptance test criteria from the customer up-front. This helps solve the greatest risk of all – getting the wrong product.
* Define your definition of "done" up-front so that there’s no argument at the end.
* Ensure you build quality in right from the start.

The conclusion can be split into two areas

  1. Understanding the Requirements
  2. Getting your process right

Getting your process right is something the development teams control,  and there is a lot of information out there today about techniques like Test Driven Development, Continuous Integration and the like that all focus on the development process and quality.  

Understanding the the requirements on the other hand and getting the business to provide you with valid and testable user stories is an area of agile development that I feel has been neglected.  There are great books that have been written on how to write user stories and how to ensure they are testable.   There are other books aimed at the business analysts about how to gather requirements.  However these have never come together, agile development teams don’t look much be the user stories. 

This pushing back beyond the user stories and into the way requirements are gathered and the business is understood is something I have been working on for a while.  And with this push back beyond the user story it is clear the way to get business and customer buy in to the agile development approach is to really change the way businesses approach the complex problems they are trying to solve.

I have some really exciting things to announce over the coming weeks that will really take this discussion forward, working with some of the most visionary guys in the field.

Rest assured there will be a very big SharePoint focus.

Monday, May 4th, 2009



UPDATE:  Project Aberdovey is now live and called 21SCRUM

Download a trial from www.21scrum.com

Being an advocate of SharePoint as an application platform I looked long and hard for a decent implementation of a Scrum and have always been found wanting.  I have seen simple examples where any power user could set things up but found the lack of any Burndown charts meant you lost probably the most important part of Scrum – the visibility.

I have found that VersionOne is one of the best products on the market, although it has a lot of options which tends to put off new teams.

For those that use Team Foundation Server your probably going to head towards the Scrum for Team System developed by Conchango.  I’ve not used this in anger so am unable to comment on how well it works however this solution is not really a SharePoint specific solution as it requires you to make the commitment to using Team Foundation Server.

Bil Simser did a good post on scrum tools,  although its nearly 3 years old still has some good links.   Again however the tools are not specifically SharePoint.

Why the SharePoint Obsession?

SharePoint is the collaboration tool of choice, companies have deployed it and it is being used with varying degrees of success.  People have become familiar with the how to add items to a list, how to upload documents into a document library and for the more advanced how to build engaging dashboards.

What is the biggest thing you get from adopting scrum?  ‘Visibility’

What do you need to encourage to make Scrum work?  ‘Collaboration’

SharePoint is the natural platform choice on which to build a Scrum tool.

Introducing Project Aberdovey

As with all good development teams I think it is right that your development project should have a name,  and in keeping with some big companies in the Seattle area 21apps uses place names.   Aberdovey, or as it’s spelt in Welsh Aberdyfi, has probably one of the best beaches in the UK and is located 50 miles west of the office.

Put simply, Project Aberdovey is a Scrum tool for SharePoint.

There are a few aims for the project:

  1. Produce a fantastic Scrum tool built on SharePoint
  2. Develop the solution using agile techniques including TDD
  3. Dogfood the solution as soon as possible – what better way to develop the right solution
  4. Open development – I want to give feedback on the challenges but also welcome your input

I will be looking for ways to give people visibility,  I am looking at codeplex as an option but welcome any suggestions.

Thursday, April 23rd, 2009



Great to see that more people are publishing their experiences with unit testing SharePoint.   Here are some of examples I have found that are really worth looking at:

Richard Fennell – Testing SharePoint Workflows using TypeMock Isolator (part 1, part 2 and part 3) – Richard is also going to be talking at a few NextGen meetings on the subject.

SharePoint Dev Wiki is really starting to get some good content not just on unit testing but on the whole development field.

Jeremy Thake (creator of SharePoint Dev Wiki) did a great usergroup meeting web cast on SharePoint Development with Unit Testing

I’ve previously mentioned the Patterns and Practices work and they have started to do some great Channel 9 videos which really do make this so much more accessible.  Brilliant Job!

If you have any links or posts on the subject please share by adding a link in the comments, and if you’ve done something new and exciting help the SharePoint Dev Wiki by posting details.

Looks like my predictions are starting to come true,  people really are doing SharePoint development better :)

Friday, April 10th, 2009



I was planning to write up a post conference summary as a reminder to myself about the highlights.   The problem was that the whole conference was a highlight. So rather than write my own notes I thought I’d highlight some of the comments other people have made

As you know sometimes its just better to twitter

@lespaulrob: Hats off to @SteveSmithCK and team for putting together a great show at #spbpuk! the best run conf i’ve ever had the privilege to attend!

@SteveSmithCK: Appreciate all the comments everyone. Without a doubt all the hard work was worth it and I will definitely do another one #spbpuk

@molnaragnes: @SteveSmithCK Thanks again for the opt it was a very-very great event! See you soon! #spbpuk

@Nellymo: RT : @SteveSmithCK one word….QUALITY!!! that’s what the European SharePoint Best Practice conf. #spbpuk was all about”

@harbars: chilling out after #spbpuk great event – thanks to the entire CK crew

@brianwilson1: Thanks to all for awesome SharePoint Conference! Had a great time sharing cool tips on virtualizing SharePoint! #spbpuk #spbpc

@itwyatt: on my way home from #spbpuk , sad to be leaving its been a great few days – hope you’ve all enjoyed it.

@fatalfrenchy: As sun sets on sharepoint the moon rises on sharepint… had a great few days, def. worth it and would love to do it again Chris ;-) !#spbpuk

@RPWillis: #spbpuk Almost home after a great conference. Fantastic buzz and speakers,

@Erwin8: #spbpuk was a super conference, great organisation. too bad it’s over!

@ianmoran ditto – queuing at Gatwick but been well worth it. Best conf I’ve been to! #spbpuk. Well done @stevesmithck and all speakers

@StephenHynds: @SteveSmithCK #spbpuk conference was excellent. Lots to think about on the train back to Glasgow. Same time next year?

@markvlunenburg: #spbpuk ask the dev experts panel. I had a great conference! Thanks guys!! http://mobypicture.com/?ljfu5l

@helloitsliam: Great Conference, speakers and great to meet tons of people. Hopefully see you all again. Big respect to @SteveSmithCK!! #spbpc #spbpuk

Mark Rackley has also done a great summary from the twitterverse.

But for those that have more than 140 characters to say,  blogging works a lot better, although takes a little longer to get together.

What can I say about the conference?

Really just need to say massive great big thanks to Steve Smith @ Combined Knowledge for organizing a fantastic event. The Venue, Speakers, Sessions and Everyone there was fantastic.

Liam Cleary

Day 3 of the SharePoint European Best Practices Conference

Really had a great time over the last 3 days and will definitely go again

Justin French

These are just the examples I found; If I’ve missed you add a comment with a link back to your post.   I had a great time meeting people new and old and can’t wait for the next time. Vegas anyone :)

Monday, March 30th, 2009



Unless you’ve been hiding under a bush for the past year you will have heard all about the fantastic Best Practices SharePoint conference’s that have taken place in Washington and San Diego.  Showing that you don’t have to jet across the Atlantic to see the best speakers the European Best PracticesT SharePoint Conference comes to London from April 6th thru 8th 2009.

Perhaps you looking to see Governance Man (Joel Oleson) for real,  share a pint with Andrew Connell, meet the infamous Bob “Praise Bob” Fox, the list goes on and on with probably the best bunch of speakers to gather in one place.

Whether your an IT Pro, Developer,  Information Worker or involved in business decision making you need to make sure your at the conference.

The three day agenda is packed with additional Lunchtime sessions recently added.

Myself I’m going to pick up where I left off discussing Test Driven SharePoint development from the recent SharePoint PodShows,  Monday 4:15 to 5:30.  Be sure to attend where I hope we can continue the discussion with Eric Shupps (SPTDD: SharePoint and TDD, Part One, SharePoint and TDD – The other view).

On Wednesday, Alex Pearce and I will be doing a lunchtime session on SharePoint in Education as part of the SUGUK.   In the UK we really do seem to be leading from the front on this area of SharePoint adoption and want to encourage more debate and community involvement to help Education get the most from their investment,   This will be an open mic session where people can share there experiences (good, bad and ugly).

Finally there will be the now legendary SharePoint by Day, SharePint by Night

Venue:  The Old Star, 66 Broadway, Westminster, London, SW1H 0DB

Date: Wednesday 8th April

Time: 7pm – till late – no ones speaking the next day :)

Look forward to seeing you all in London very soon.

Tuesday, February 24th, 2009



As development practices around the SharePoint platform mature the demands for better quality and better performing solutions are being made.  Gone are the days when Enterprises will accept that the Roll-Up Web Part they purchased will not scale beyond a few site collections.  A knowledge of the platform and defensive coding alone will not cut the mustard, the need for a holistic approach to your development practices will be the only way to achieve success.  In this blog post I am focusing on one specific technique, code profiling, and using the excellent Red Gate ANTS Profiler.

Disclaimer:  Red Gate ANTS Profiler is a paid for application.  There are other products on the market that do code profiling including Visual Studio.  The reason for using ANTS in this post is due to the ease with which you can get up an running and the quality of the user experience.  I recommend you set aside a day to look at the profiling in Visual Studio and then a few hours to get that much further with ANTS.

Software Performance Analysis – Wikipedia

In software engineering, performance analysis, more commonly today known as profiling, is the investigation of a program’s behavior using information gathered as the program executes (i.e. it is a form of dynamic program analysis, as opposed to static code analysis). The usual goal of performance analysis is to determine which sections of a program to optimize – usually either to increase its speed or decrease its memory requirement (or sometimes both).

As the quote says this technique is specifically aimed at the optimization of code; the tools enable the developer to quickly target the areas of code that need optimization and lead to an improved return for the effort. (seems strange saying ROI when talking about dev techniques, but this is really what it is).

Getting started

Red Gate provide a 14 day trial, so you can try before you buy.  The latest release, version 4.3 as at the time of writing, has made some great improvements over the 4.1 version – most notably the removal of the need to stop all the IIS web sites listening on port 80 :) .

As you would expect this post will focus on profiling SharePoint code, I’m going to use the Magic 8 ball application developed for my TDD session at the Best Practices SharePoint Conference in San Diego.

More details on Test Driven SharePoint development can be in the Agile section of this site.

Environment

The environment that I will do the testing is a typical SharePoint developers Virtual Machine.

  1. Windows 2008 Server (32bit)
  2. Visual Studio 2008
  3. Microsoft Office SharePoint Server 2007
  4. SQL Server 2005

As this is running on Windows 2008 I will be testing against IIS7.   The requirements are identical for Windows 2003 and IIS 6.0

Installation

Download ANTS Profiler and install, not too many options to worry about here.

image

Luckily for my first run through the team have provided a technical paper on installing, using and getting ANTS Profiler to work with SharePoint, How to profile a SharePoint 2007 Site Collection.  There were a few things in here that I prefer not to do,  I will document what I do below and will pass this back – I’m not criticizing, there’s no way I would even attempt to write a Profiler so mucho respect from me to the Red Gate team

Configuration

We are looking for the ability to profile any site collection within a Web Application.  This involves getting the account used for the associated application pool, giving it some additional rights and then configuring the ANTS services to use this account.

Web Application

Depending on your development machine configuration you will have a number of web applications configured in SharePoint, the configuration below should be reasonably familiar to most of you.

image

The key here is to identify the web application (IIS Website) as we need to get the account name from the associated Application Pool.

Load IIS Manager, select the web application and chose Basic Settings from the Actions menu on the right.  This will show the associated application pool as below.

image

Select the Application Pools from the connections menu, choose the application pool identified in the previous step and click advanced settings.  This will give you a properties screen showing the account we need to work with.

image

In this case 21apps\svc-intranet-ap – if you have a local installation this may be set to Local System in which case the steps below may not be required.   I recommend that dev’s don’t have a default install as you really need to understand how SharePoint is setup to undertake any large scale developments.

Web.Config

In IIS 6 days you would need to edit the web.config file to set the application into debug mode.   In IIS 7 the common ASP.NET configuration options have been promoted to the IIS console.  With the web application still selected click on the .NET Compilation option and change the Debug behaviour to True and click Apply.

image

Like all good SharePoint developers you will be working with WSS_Minimal trust settings or a custom policy file.  To do profiling however you will need to set the Trust level to Full.  Again IIS 7 provides a UI or you can edit it manually.

image

It is possible to run the code without setting a Full trust level, but you need to remove the .pdb files and will lose the ability to profile the lines of code.  Which is sort of the point of profiling!  If you don’t set Full trust you will get an error like the one below when loading a web part

Web Part Error: An error has occurred.

Show Error Details
Hide Error Details 

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
  at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
  at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
  at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
  at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly)
  at System.Activator.CreateInstance(Type type, Boolean nonPublic)
  at System.Activator.CreateInstance(Type type)
  at Microsoft.SharePoint.WebPartPages.SPWebPartSerializer.get_DefaultControl()
  at Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.SerializedWebPart..ctor(SPWebPartManager webPartManager, XmlNamespaceManager xmlnsManager, Byte[] sharedData, Byte[] userData, String[] links, Type type, SPWeb spWeb)
  at Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.Deserialize(SPWebPartManager webPartManager, XmlNamespaceManager xmlnsManager, Byte[] userData, Byte[] sharedData, String[] links, Type type, SPWeb spWeb)
  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts)

[VerificationException: Operation could destabilize the runtime.]

Services

ANTS runs as two services

  1. ANTS Memory Profiler 4 Service
  2. ANTS Performance Profiler 4 Service

Change the accounts on these two services to the same accounts used in the web application we identified above.

If this is the first time the account has been associated with a service it will be automatically granted the ‘Log On As A Service’ right.

image

Local Security Policy

From the Administrators menu choose Local Security Policy and grant the application pool account the following rights

  1. Act as Part of the Operating System
  2. Impersonate Client after authentication

image

Open a command prompt and run gpupdate /force.

image

Profiling your code

Your environment is now configured, we can start profiling.  As this is SharePoint I tend to just hit the bit i’m planning to profile first to make sure this is working before I start profiling.  Many hours can be lost trying to solve a configuration issue with a profiler that is not at fault.

Start Red Gate ANTS Performance Profiler.  It knows we’re running on a system a system that has UAC, it offers to make our life easy and always run as an Administrator.  I normally click yes here.

image

ANTS loads the Profile Settings window is automatically.

There are only a few things to set.

  1. Choose the ASP.Net web application (hosted in IIS)
  2. The URL to the SharePoint site
  3. Use the original port

image

Further profiling counters can be set, but we just want to get our first run going for now.  Click on Start Profiling.  (In this example I have added a long running process to show how ANTS can identify this as a hotspot).

Profile Results

Profiling will start and a new browser will open at the location specified.  As this is SharePoint the profiler restarts the service so you will always have a small delay while SharePoint is JIT compiled. The profile timeline will show this impact on the processor.

image

Once the processor has levelled out its time to start profiling your code.   Navigate and interact with the bit of the application you are interested in.  If it is a  web part or navigation load you are interested in then you can refresh the page.

Once you are happy you have performed enough tasks,  I recommend keeping these focused, stop the profiling. ANTS will present you with the HOT code, the bit of code that is the worst performing. You can focus the analysis on any part of the profile graph to show poor performing code around a specific spike in the processor or memory.

image

In the example above I am focused on the code that runs (including my long running process) when I ask the magic 8 ball a question.

Viewing source code when you have enabled Line level profiling shows every line, the hit count and the % of time taken to perform that operation.

image

The really cool thing is you can click through the methods to follow the slow running process through the code!

image

Showing the method grid allows you to open up a call graph for any method to see how the processing is broken down in a dynamic tree view.  This really is just brilliant!  The image below does not do it justice you really do need to see this for yourself to appreciate it.

image

Conclusion

The long running process I added for the demonstration was picked up and allowed me to drill down into the lines of code that were the slowest.  It even showed how the internal calls within the base classes performed.

Red Gate ANTS Profiler is easy to setup and proves to be an invaluable tool in your software development tool kit.  I suspect profiling will not be something that you do every day, however with the speed and ease of use I would like to think that you will consider the inclusion of profiling a must have rather than a nice to have.

Sunday, February 22nd, 2009



Ever wondered what it is like to be on 3rd line support at Microsoft?  The client calls in with a really obscure error that only happens some of the time?  No me either,  but the past few days have probably been pretty close.

The Problem

I am working on a Silverlight/SharePoint solution, that will take the Education world by storm in the not too distant future, which was throwing a very strange error during the creation of a SharePoint web (SPWeb).

   1: MESSAGE
   2: System.NullReferenceException
   3: Object reference not set to an instance of an object.
   4:
   5: STACK TRACE
   6:    at Microsoft.SharePoint.Utilities.SPUtility.StackTraceString(Int32 numLevelsToSkip)
   7:    at Microsoft.SharePoint.SPList.TraceListOperation(String operation, Boolean recordStack)
   8:    at Microsoft.SharePoint.SPList.Update(Boolean bFromMigration)
   9:    at Microsoft.SharePoint.SPList.Update()
  10:    at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.AddCore(SPWorkflowAssociation wa, Guid id, SPList list, Boolean forceUtilityListCreation)
  11:    at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.AddCoreCT(SPWorkflowAssociation wa)
  12:    at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.PushDownAssociation(SPWorkflowAssociation associationTemplate, Boolean bUpdateIfExisting, MethodBase mbChangeEntry)
  13:    at Microsoft.SharePoint.Workflow.SPContentTypeWorkflowAssociationCollection.CopyWorkflowAssociation(SPWorkflowAssociation associationTemplate)
  14:    at Microsoft.SharePoint.SPContentType.CopyWorkflowAssociationsTo(SPContentType ctDst)
  15:    at Microsoft.SharePoint.SPWeb.SyncNewLists()
  16:    at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(String strWebTemplate)
  17:    at Microsoft.SharePoint.SPWeb.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere)
  18:    at Microsoft.SharePoint.SPWeb.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere)
  19:    at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere)

The problem was happening during the creation of a standard Team Site, although it only happened on some of the SiteCollections and not on others.  Although the error was fired the actual web was actually created, and if you created the site through the UI it did not report and error.

Concern One: The UI is handling and ignoring these errors, if they are not important why would the API through them?

Reading through the errors the problem is rooted in the method Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.AddCore which is obfuscated which makes debugging that bit harder.  The method lived deep inside Microsoft.SharePoint.SPWebCollection.Add

Diagnosis

The diagnosis process went through a number of iterations, comparing the sites that worked with those that didn’t. Eventually a small console application was created to look at the types of Work Flow Associations that existed for each of the content types and lists.   The console application accepts one parameter, the web url.

if (args.Length == 0)
{
    Console.WriteLine("Enter URL to web");
}
else
{
    using (SPSite site = new SPSite(args[0]))
    {
        using (SPWeb web = site.OpenWeb())
        {

            Console.WriteLine("***************************");
            Console.WriteLine("Workflow Templates");
            Console.WriteLine("***************************");

            foreach (SPContentType contentType in web.ContentTypes)
            {
                Console.WriteLine(contentType.Name + " - " + contentType.Hidden + " : " + contentType.Scope);
                foreach (SPWorkflowAssociation workflowAssociation in contentType.WorkflowAssociations)
                {
                    Console.WriteLine("WFA:" + workflowAssociation.Name);
                }
            }

            Console.WriteLine("***************************");
            Console.WriteLine("Workflow Templates");
            Console.WriteLine("***************************");

            foreach (SPWorkflowTemplate template in web.WorkflowTemplates)
            {
                Console.WriteLine(template.Name);
            }

            Console.WriteLine("***************************");
            Console.WriteLine("Lists with WF association");
            Console.WriteLine("***************************");

            foreach (SPList list in web.Lists)
            {
                if (list.WorkflowAssociations.Count > 0)
                {
                    Console.WriteLine(list.Title);

                    foreach (SPWorkflowAssociation workflowAssociation in list.WorkflowAssociations)
                    {
                        Console.WriteLine("WFA:" + workflowAssociation.Name);
                    }
                }
            }
        }
    }

    Console.WriteLine("END");
    Console.Read();
}

The output from this application was quite telling but did not provide the exact cause of the problem.  It showed that the Document content type on the sites that worked had no associated workflow.

Whereas the ones on the sites that did not work did have workflows associated with this core content type.

But this just pointed to some Site Collection level features that had been activated on this site that were not on the other.   Deactivating these features did not help.  Note: others have posted warnings about deactivating these types of features, however I was in a proving environment and could easily restore so this was not such a big issue.

The garden path

Continuing the investigation I felt like I was being led up the garden path however it was this path that lead me to the solution.  I wanted to get rid of any workflows and bring the working and non working sites in line.   I needed to remove these workflow associations from the site that was not working to see if the API call would work.

From Site Content Types gallery I chose the Document content type and workflow settings.   I wanted to stop the workflow from being associated with any new document libraries created using this content time, so in effect all libraries.

The error message that is returned from this function is much more informative.

Feature '75a0fea7-1651-4b91-8cdf-3f24e57526ed' for list template '7149' is not installed in this farm.  The operation could not be completed.
Feature '75a0fea7-d31d-491a-9177-f0e461a81e3f' for list template '1010' is not installed in this farm.  The operation could not be completed.
Feature '75a0fea7-d31d-491a-9177-f0e461a81e3f' for list template '1010' is not installed in this farm.  The operation could not be completed.
Feature '75a0fea7-9507-49c7-a473-0ce55c18ef89' for list template '240' is not installed in this farm.  The operation could not be completed.
   at Microsoft.SharePoint.SPContentType.PushDownChanges(CodeToPushDownChangesToDerivedCT derivedCTPushdownCode, CodeToPushDownChangesToListCTs listDerivedCTsPushdownCode, Boolean throwOnSealedOrReadOnly)
   at Microsoft.SharePoint.SPContentType.UpdateWorkflowAssociationsOnChildren(Boolean bGenerateFullChangeList, Boolean bPushdownDerivedCT, Boolean bPushdownListCTs, Boolean bThrowOnSealedOrReadOnly)
   at Microsoft.SharePoint.SPContentType.UpdateWorkflowAssociationsOnChildren(Boolean bGenerateFullChangeList)
   at Microsoft.SharePoint.ApplicationPages.RemWrkflPage.BtnSubmit_Click(Object sender, EventArgs e)
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

This function was looking to do very similar things to the failing call above and PushDownChanges to the content type.   However the error message here revealed that I had some missing features.

What do you do when you get a GUID in an error message,  your search for it.  Thank fully Robert Bogue had done one of those obscure but ultimately very helpful posts about the features in his farm.  And even more thankfully Robert had also installed the Fab 40 features into his farm.  As this revealed that the the proving environment these did not exist.  However they had been deployed in Live.

The Root Cause

It is difficult to exactly pinpoint the root cause,  my objective has been to remove the associated workflows to enable the web to be created through the API.   After installation of the Fab 40 WSP based solutions I was able to remove the workflow,  I tried the No New Instances option without success, the setting was applied but still the web would not create.

The Solution

The solution in this case was to remove the workflow,  this will have the consequence of removing all running instances of the workflow.   I hope to spend more time fine tuning the solution so ensure that the minimum of fixing up can be applied.

Lessons Learnt

Management of your proving environment is as critical as live.   Process and rigor should be put in place to ensure that the environment your using meets it’s needs,  in this case it was to mirror live.  Any short cuts that you have to take in order to meet business needs, such as a site collection restore over a full database restore could have implications that have unexpected consequences.

SharePoint is a very complex and often fickle platform,  to support, maintain and nurture your installation will require patience, time and a will to get to know its little foibles. Ultimately it will be rewarding, sometimes it just doesn’t feel like that.

Thursday, February 19th, 2009



My friend and fellow SharePoint MVP Eric Shupps has been promising to enter the conversation, started a number of years ago by Spence Harbar, and provide his wisdom and views on why he thinks TDD in SharePoint is just wrong!  It has been debated over email and over a SharePint for many many months.   Finally Eric has put pen to paper (or fingers to keyboard) and joined the conversation.

SPTDD: SharePoint and Test Driven Development, Part One

I now know why it took Eric so long to get his post out,  it’s taken me an hour to even read it.   As with any good debate Eric managed to get me pondering his views, what I see as misconceptions and ideas and I will be coming back with a number of posts in response.  Sorry I just can’t write that much in one blog post :)

I will start by countering a specific part of the of Erics post for the moment;   TDD has it’s origins in Extreme Programming but it is not intrinsically linked to pair programming.  I think Eric has been mislead by some more zealot supported of TDD on this.  He did however miss one of the main benefits of pair programming in his complete dismissal of the approach which is Shared Knowledge.   Later in the post he talks about lack of knowledge, poor quality developers, and also the ability to be able to actually code against SharePoint before you try something so difficult as unit testing.   Pair programming can help in this regard – but it’s something you really need to have a desire to make work.   I have used it,  it’s not for everyone and you will always have personality clashes!  I have found it to be very useful in specific areas and in small chunks.  If you do get a few really good pair programmers I think you can see improved productivity – the reality however is most people never give it long enough to see the benefits.