Wednesday, December 23, 2009

SharePoint Best Practices Analyzer Rules

I needed to extract the list of default best practices from the Microsoft Best Practices Analyzer for Windows SharePoint Services 3.0 and the 2007 Microsoft Office System. The best practices are encoded as rules in the tool’s XML configuration file. Bill Baer has a great blog post discussing it as well as how to add custom rules for the tool to check. So you can see the rules’ titles and explanations by inspecting this file, except that it is pretty hard to read.

When you run the tool, it first downloads an update to its configuration file then goes on checking the rules. I found it easiest to update the configuration file then write a little XML parser and dump each default rule’s title, category and description into an Excel file.  You can download it here.

Thursday, November 19, 2009

Cannot Edit SharePoint 2007 List in Datasheet after Office 2010 Beta is Installed

I couldn’t wait to set up the Office 2010 beta, which became available this Monday. One interesting issue I’ve ran into was this:

1. I installed 64-bit version of Office 2010 Professional Plus beta (en_office_professional_plus_2010_beta_x64_x16-19234.exe version 14.0.4536.1000) on a Windows 7 box. I was forced  to uninstall Office 2007 Ultimate I had there before in order to proceed with the 2010 setup.

2. Today I went to my SharePoint 2007 intranet site and attempted to edit a custom list in datasheet view. I’ve got an error “The list cannot be displayed in Datasheet view…”:

image 

It turned out that IE 8 zone security was fine – I was missing ActiveX component necessary for datasheet editing, the ListNet Control. This control is packaged inside STSLIST.DLL library. The library was deployed to %ProgramFiles%\Microsoft Office\Office14 directory, but wasn’t registered as a COM server, which resulted in failure of JavaScript on SharePoint page to create an instance of the corresponding ActiveX control for the ListNet.ListNet progID.

Various editions of Microsoft Office 2007 include SharePoint support component, which is installed by default: Microsoft Office >> Office Tools >> Windows SharePoint Services Support. Specifically the “Edit in datasheet” feature is supported by the sub-component named “Microsoft Office Access Web Datasheet Component”. I went and checked out the components installed for my Office 2010 – and the analogous components were marked as installed:

image

Now that appears to be an issue. It would be interesting to know if anyone else ran into the same situation or was it just me. The workaround was easy – install back Windows SharePoint Services Support for Office 2007. Below is a screenshot – I only needed this specific part of the office and nothing else:

Install

Now the “View in datasheet” worked for me. Interestingly, it appears as that both Office 12 and Office 14 versions got registered as a result. Here is the view at the COM object registry settings using oleview.exe tool (part of Visual Studio tools):

Oleview

Hope this saves somebody time. Also here is a link to a good post made by Jose Barreto, which lists all SharePoint 2007 ActiveX controls.

Thursday, October 29, 2009

SPC 2009

It was a major event at a major venue. Organization was perfect: About 7500 attendees, most of whom were customers, enjoyed a total of ~300 hours of presentation material, over 40 hours of hands-on labs, were well fed and entertained (the 80s party night was a blast!).

To me SPC 2009 was a great learning and networking opportunity. It was great to meet new people and to see people I have worked with in the past, including instructors and folks from SharePoint MCM3 rotation. Out of what I managed to attend, my favorites were both keynote presentations, business continuity management presentation by Doron Bar-Caspi and Bill Baer, and hands-on labs.

Keynotes were done with superb quality, which definitely draws on art besides the knowledge.

I enjoyed listening to Bill during MCM course, and during SPC he and Doron have delivered the best technical presentation out of the ones I’ve attended.

SPC2009s Hands-on labs helped me to quench my zest for playing with 2010 in the absence of Beta 2. In fact I’ve spent significant time in the lab knowing that recorded presentations would be available later. The lab room itself was impressive. The picture shows about 2/3 of it.

Thanks to the SPC organizers!

Friday, July 31, 2009

Software Estimation: Demystifying the Black Art

It was a mere curiosity that made me buy this book - I didn't have a major project to estimate, I was finding the subject rather interesting especially having past experience observing various approaches and politics around software estimation. I was well rewarded for my interest - Steve McConnell delivered an easy, exciting and to the point reading experience once again. The book provides an excellent summary of decades of research in this important area, and is meticulously compiled and enforced by Steve's own expertise and opinion. More so the book is filled with practical advice and industry data, which makes it useful as a reference to get started estimating software THE PROPER WAY!

Tuesday, June 30, 2009

Completed SharePoint MCM Training Rotation 3

SharePoint MCM certification is the topmost technical certification in Microsoft Office SharePoint Server 2007. A little over a week ago I have completed the 3-week training in Redmond. I have yet to get my certification though as I have passed only some of the exams. Fortunately there are retakes available so my challenge is still on. The SharePoint MCM certification training course had 3 exams, each at the end of the corresponding week, plus there was a full-day qualification lab on the very last day.

Was the course useful? It was the most challenging training I have ever taken, it challenged my knowledge, time management skills and ability to keep up with 15 hour working days for 3 weeks. I was fortunate to meet with people who all were very solid SharePoint professionals already (we had 16 students in class), and learn from them. The course instructors were excellent, and also well-known names in SharePoint community. It was exciting to meet them in person with plenty of time for asking any level of depth of technical questions. Some of the course material was simply the best and hard to get anywhere else. Each student was provided with excellent hardware for doing labs. Most of us do not have that level of lab environment at work. And I definitely know much more about the product now, which by the way helps me being better prepared for working with its next version. Lastly, the exams were a challenge – I still have work to do there. So the experience was worth every dollar I’ve spent on it. I’d like to thank the organizers of the MCM training here, and especially James Petrosky who made this course a great experience for years to remember.

I would recommend my colleagues in SharePoint community to go to this course since even during the weak economy the best investment you can make is into your knowledge. You won’t go bankrupt because of this! Even, and especially if you are seasoned, you would be surprised by how much more there is to learn about the product.

Sunday, May 24, 2009

jQuery on my Home Page

For a while I thought of adding some animation to my home page and so finally I got to doing it with help of scrollable jQuery plugin from flowplayer.org. It is really easy compared with old reusable JavaScript components – standard indeed matters, plus great documentation on this particular plug-in made its integration very simple. Aside from some minor CSS work I had to add just a few lines of scripting code to make it all work:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="styles/jquery.scrollable-1.0.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
$("div.scrollable").scrollable({ size: 3 });
});

function moveNext()
{
$("div.scrollable").scrollable().next();
}

function movePrev()
{
$("div.scrollable").scrollable().prev();
}
</script>


Thursday, April 30, 2009

Debugging SharePoint Timer Jobs

When working on a SharePoint project recently I was faced with complexities related to development of SharePoint timer jobs, or more precisely – ones related to ensuring their proper quality. Indeed the timer jobs are not trivial when it gets to their debugging. Below is my approach to dealing with the issue:

1. First things first – you need to install your timer job, likely using a custom feature receiver. I am quoting Andrew Connell again, he has an excellent post describing the details.

2. You want to be able to start your timer job explicitly during testing (SharePoint does not let you do this other than through the API). There are two obstacles here:

- firstly you need the harness code to invoke the API,

- secondly you need to impersonate the identity of the Timer Service when invoking the API.

I have chosen to “abuse” the Unit Testing infrastructure given to me by Visual Studio to host my harness logic. You can either do the same or write a console application for this purpose. My unit test thus looked as follows:

[TestClass]
public class TimerJobsTest
{
private Impersonator impersonator;
private SPSite site;

public TimerJobsTest()
{
impersonator = new Impersonator();
}

[TestInitialize]
public void Initialize()
{
using (SecureString securePassword = new SecureString())
{
// Omitted setting secure password and
// retrieval of other variables for brevity.
securePassword.MakeReadOnly();
impersonator.ImpersonateUser(
adminUserName,
adminDomain,
securePassword);
}

site = new SPSite(siteUrl);
}

[TestMethod]
public void TestJob()
{
foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
{
if (job.Title.Equals(
"My Job Title",
StringComparison.OrdinalIgnoreCase))
{
job.Execute(site.ContentDatabase.Id);
break;
}
}
}

[TestCleanup]
public void CleanUp()
{
site.Dispose();
impersonator.StopImpersonating();
impersonator.Dispose();
}
}

As you see I was using an Impersonator class, which allowed me to control the user identity when invoking my job. This is a custom class I wrote for this and similar situations. You can get its source code here. It is far from being a rocket science (and it shouldn’t be) as it is using the old common Win32 impersonation API. Yet one thing about it is interesting: using SecureString type, something I was referring to in my earlier post. If you examine the code of Impersonator.cs, you could see how the managed SecureString is marshaled to the unmanaged code when the Win32 API is called. By the way if you are ever using WPF PasswordBox control, it is capable of passing on a SecureString containing password as of .NET Framework 3.5 SP1; then my impersonator becomes really handy.
True, you don’t need to be fancy when testing your own code. The Impersonator.cs is meant to be a reusable secure facility for impersonation so it adds some overhead. Feel free to change it if you do not intend to use it in production environment.

3. Once this is done, you set breakpoints, attach to the WSS Timer Service process and step through your job’s code as (I hope) you normally do.

Friday, April 17, 2009

Preparing for the SharePoint MCM Course

If you check out recommended pre-reading list for the Microsoft Certified Master training in SharePoint, you will find that it presents a great deal of work. Since I have to also manage my job and my family time it becomes quite a challenge.

So I needed to measure the volume of preparation work. I've transferred the items to an Excel spreadsheet, added up video hours, and summed up all book pages together. As there is a lot of online content I printed it to PDF to estimate number of pages, and added them up as well. This was an approximation because there were lots of cross-links, but it nevertheless gave a good idea of the overall volume.

The resultant Excel table lists pages and applicable video hours for each item. Also it counts down remaining days before the course start and lets you adjust average number of hours you can spend on studying daily as well as your hourly reading rate. This way you can see whether you will make it with your reading on time, or if you need to free up more of your time. You can download the spreadsheet here.

Monday, March 16, 2009

I am Accepted to MCM SharePoint 2007 Course

Last week I was officially accepted to take the Microsoft Certified Masters training course in Microsoft Office SharePoint Server 2007. I can’t wait to fly to Redmond and get started on this 3-week course between June 1 and June 20th. I plan to post updates on my experiences preparing for the course and taking it. So far it was quite an investment of mine but pleasantly I did qualify for a 30% discount by applying early. Also judging by how the interviewers virtually tore me apart, I am expecting a survivor-type mind grinding training. Well it means it will be worth the money...

Tuesday, February 3, 2009

Framework Design Guidelines

I have noticed a book titled "Framework Design Guidelines" by Krzysztof Cwalina and Brad Abrams on my colleague's desk last week and asked if I could borrow it for a few days. Now that I've read it, I strongly recommend it to any .NET developer considering himself or herself senior. I actually plan to buy the book as it will make a great reference.

The book provides a comprehensive overview of best practices for design of reusable components, most of which should be familiar to a good developer working with .NET for some time. Even though the advice in the book is based on the experiences of .NET Framework implemnentation, which is targetting millions of people, it is perfectly well applicable for smaller frameworks. If you have enjoyed books like Code Complete by Steve McConnell or Jeffrey Richter's Applied .NET Framework, you will like this one too. Check this book out!

Saturday, January 31, 2009

Organize your Feature Receivers

At imason I have done a lot of work with SharePoint feature receivers. As the size of solution grows, so does the number and complexity of feature receivers. This makes developers treat installation logic that lives inside feature receivers with necessary care. It is no longer some dirty through-away code and all the proven architecture techniques perfectly apply to it as well. See the full post here.

Wednesday, January 28, 2009

Toronto SharePoint Code Camp 2009 - Great Venue, Great Organization

I was presenting at the Toronto SharePoint Camp for the first time last weekend. The event has exceeded my expectations by all accounts. The venue and the organization were excellent, and the great turn-out has demonstrated a strong interest in SharePoint and growing developer community around it. Great thanks to Ed Musters and other organizers for this great event!

My topic was named "Effective Deployment of SharePoint Publishing Sites", and was largely based on the idea of authoring a custom XML document representing site hierarchy, including variations, sites, pages and web parts. Deployment automation logic would then consume this document and create actual site hierarchy from it - something I have been blogging about earlier. I have also touched on a quite interesting subject of how to assess the worthiness of an upfront effort investment into deployment automation. You can download my presentation here.

Thursday, January 15, 2009

Show Alternating Rows in Content Query Web Part

Often you need to display alternating rows in a Content Query Web Part (CQWP), so that for example you get a record on a white background, then a record on a gray background, then on white again etc. Yes, you can create a special “index” column in your source content type and based on its value determine if a given row is odd or even.

There is a better way however: from within your ItemStyleTemplate.xsl you can know the position of the current node, which you can always translate into the knowledge of whether the current row is odd or even:

<xsl:template name="AlternatingItems" match="Row[@Style='AlternatingItems']" mode="itemstyle">
<xsl:variable name="CurPosition" select="count(./preceding-sibling::*)" />
<xsl:variable name="AlternatingCssClass">
<xsl:choose>
<xsl:when test="($CurPosition mod 2 = 0)">
<xsl:value-of select="'CssClassAlt1'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'CssClassAlt2'" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
… the rest of the template

On a related but different topic, in order to have a field exposed to your XSL file as an attribute of the Row XML element you typically need to export the CQWP to a file then edit its property named CommonViewFields as perfectly explained by Heather Solomon here.

The only thing calling for some expansion after reading this blog post is how to know which field name and which type name exactly to feed into the CommonViewFields property. The definitive source of the information about which fields are there and which are their types is located in here:

%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\fields\fieldswss.xml

Each field in this XML file has a Name attribute and a Type attribute, their values can be fed into the CommonViewFields property of your CQWP. Ideally we want to be able to list all applicable fields based on currently selected options for the query, but this would require extending the web part itself…