Skip to content

Why We Build WSPs and Option Explicit

Recently I got called in to look at something by a client and in a part of the process it became apparent that the developer hadn’t created a SharePoint Solution (WSP) to deploy the solution. That and the lack of a centralized Visual Studio project made the problem really hard to find. The conversations were effectively … “Well, we’re going to do that when we’re ready to deploy it.”

This whole thing reminded me vividly of a conversation I had with a developer of mine that happened nearly ten years ago. At the time ASP was the name of the game. It was a huge jump forward from trying to write web applications with CGI-BIN. The problem with ASP pages is that they used VBScript for their development language. VBScript was/is a bad language. It was hard to debug and had all sorts of odd side-effects that you had to learn to expect. One of the really challenging things with VBScript is that by default it allows you to just use variables — they don’t have to be declared. This sounds like a great timesaving features. You don’t have to write the code to declare the variables.

In reality this is a pretty pesky thing. What happens is that you mistype a letter in a long variable name and they don’t see it. When the code EXPECTS that a previous line set a value and it doesn’t happen weird/bad things happen. This particular developer called me over from time-to-time to help him look at problems in his code — I was happy to do it. However, after about the fourth time I had found the issue was that he mistyped a variable name, I was tired of explaining how important it was to use Option Explicit. Option Explicit was a command you could put at the top of your file and among other things it would require variable declarations. The result is that if you do mistype a variable it will generate an error.

His response was that he added Option Explicit at the end of the process — before he turns the code over. Here’s the problem with that thinking — you don’t add Option Explicit because you want to, because it’s a requirement, or because you feel like it. You add Option Explicit at the top of ASP files because it makes your life easier. It saves you hours of debugging on weird issues because a variable name was mistyped. I should say that I did get to the point that where I told him if I ever found another piece of code that didn’t have it — I’d fire him on the spot no matter what. That was finally effective at getting him to help himself. I didn’t end up firing him he left on his own.

Why did this come up? Well, because we build WSPs not because it’s easy. We build WSPs because it MAKES OUR LIFE EASIER. In this situation the problem was that the particular thing showed up in one environment but not in another. That screams to me that there was some sort of a deployment error. If we had a WSP we could have tested it in a few minutes on a blank virtual machine. (Of course the problem wouldn’t have happened in the first place if the deployments were consistent.)

So the next time you’re wondering whether you should start building WSPs at the start of your project — help yourself out and do it. (Repeating for effect… Build WSPs EVERY time.)

Do you know how to leak an exception in SharePoint?

I’ve mentioned a few times that I’m participating in the patterns and practices SharePoint Guidance advisory board. One of the things I raised with regards to exception handling was that some exceptions leak past your try-catch blocks. Does anyone have scenarios they can share where this happens? I know it does it but it’s been so long that I don’t remember the exact circumstances. My email is [email protected].

SharePoint Saturday, Chicago Edition June 13, 2009

I call Chicago my second home. It’s a three hour drive up I65 but it still feels like a second home. I have family there and I seem to get there at least once a quarter. That’s why I’m happy that SharePoint Saturday : Chicago Edition is scheduled for June 13, 2009. Having participated peripherally in the planning process, I know that there are a ton of great speakers that are going to be there including my fellow MVPs Asif Rehmani, Darrin Bishop, Leonard Mwangi, Paul Schaeflein, and Todd Klindt. But wait, there’s more. (Said in my best late night infomercial voice.) Some of my SharePoint buddies, Chris Geier, Coskun Cavusoglu, Mark Miller, Michael Blumenthal, and Tony Lanni will also be there speaking.

I can honestly say that I’m expecting that this will be the best free SharePoint event in the US this year. If you’re within driving distance of Chicago … you want to make a point to make it to the event.

TechEd Online: SharePoint

You may have already seen the SharePoint development panel that several of us (Scot Hiller, Maurice Prather, Todd Baginski, Andrew Connell, Eric Shupps, Todd Bleeker, Matthew McDermott) did at TechEd North America 2009 in Los Angeles, CA. It was a great discussion about software development for SharePoint (48 minutes).

I also sat down with David Hill from the patterns & practices group to talk about the work they’re doing on version 2 of the SPG. It’s 9 minutes.

Of course there’s a ton of SharePoint related content at the conference this week — but most of that requires that you registered for the conference.

Using Word QuickParts to Enter Metadata for SharePoint

For a few years now, I’ve been talking about a technique that everyone can leverage to get metadata into SharePoint — without the users having to do something different than they normally would. I’ve talked about the general principles in the whitepaper I wrote for Microsoft “Managing Enterprise Metadata with Content Types.” That whitepaper is focused on understanding how SharePoint’s search features can be activated for use with the metadata that users enter — and it walks you through a step-by-step process for creating a word document that uses quick parts to enter metadata. For those of you that haven’t seen it, a quick part in Word sits on the surface of the document. When a user enters information into the document, the information is copied into the properties by Word. When the user isn’t hovering over the content, you can’t even tell that the text isn’t just normal text in the document. Take a look at the following which has four QuickParts on it. I’ve clicked in the one for First Name:

The net-net is that this is a quick way to convert a paper form put together in Word into a “smart form” that can be used online.

I’m often asked why I’m not talking about InfoPath. There are a few reasons, not the least of which are the issues with getting InfoPath to play nice with my content types on SharePoint. However, the other reality is that not everyone can use InfoPath. Either it’s not installed, licensed, or it’s not licensed for Forms Services on SharePoint. The final reason is because most folks know that InfoPath is SUPPOSED to handle data. It’s assumed that you can copy properties to SharePoint and back. InfoPath is much more powerful and is essential when you need a one-to-many relationship in the data. Forms like expense forms are much better in InfoPath than Word. However, there are a ton of forms, like vacation requests, which don’t need the one-to-many relationships that InfoPath would provide. It’s easier to teach end users one (or two) new things about Word documents and get forms than trying to push them into a new forms technology.

Historically, the problem with using Word documents has been that the techniques outlined in the whitepaper was only shown through the UI. I hadn’t shown how to bundle the work that was done in the Web UI into a deployable content type via a WSP package. I first started demoing this at TechEd EMEA November 2008, however, the approach I was using had a problem. You still had to upload the template after deploying the content type because of a defect (confirmed) in SharePoint. The short is that SharePoint was mangling the document when the content type was associated. However, with the help of some friends in customer support we’ve got a work around.

Typically when I’m creating content types from content types I’ve developed in the UI, I use Andrew Connell’s WCM STSADM command extensions and then strip a few things. His tools extract the exact XML in the definition of a site column. This includes the attributes for Version, StaticName, and SourceID. These aren’t attributes that should typically be set. Version isn’t supported at all, StaticName is only for the office clients, and SourceId is supposed to be set by the framework to the feature that created the field. SourceId is supposed to help you work back to the feature that created the fields. Well, as it turns out if you set this field to be the same as the sourceId for the fields that you added in via the UI, SharePoint doesn’t mangle the document template. (So leave the sourceId in — for this case only).

With this new piece of data you can create the form in the UI using the method in the whitepaper, extract the site columns and content type, create a feature for the site columns and content type, create a feature to deploy the template, and deploy them in a WSP.

There is one remaining issue. One of the things designed to help users enter metadata gets in the way. The Document Information Panel (DIP) is designed to help users remember to enter metadata. It is displayed when the user creates a new instance of a document. There isn’t a way to suppress this out of the box. Even if you go in and set a macro on the template to hide the DIP it won’t work — because the DIP is loaded asynchronously and is displayed after the AutoNew macro in Word. I believe it should be possible to create a DIP that does nothing but close itself, however, I’ve not had a chance to test it. For now, I’ve just been telling people to close the DIP manually. The DIP can definitely take up some screen real estate if you don’t.

If someone develops a technique for creating a DIP that closes itself send me an email and I’ll link to it from here.

The TechEd Gang

Some pictures from the Office TLC at TechEd 09 North America in Los Angeles

Crazy Big E (Where’s the cowboy hat?)

Wild Woody

Bogus

Manic Maurice

Tangle Todd

Dangerous Dave

Sleepy Shane

Sly Steve

Scot the Knife

MS Filter Pack and the Registry Entries

If you download the MS Filter Pack and install it on your indexer (the only place you need it) you’ve still got some registry entries to make/verify. I got tired of doing them by hand so I created a .REG file. You can download my file. Rename it as .REG (I had to change the extension to .TXT to upload it.) Then just double click it. It will make sure the entries are in place. I’d reboot after that just for good measure.

VSeWSS – Please wait while the installer finishes determining your disk space requirements

While trying to install the Visual Studio Extensions for Windows SharePoint Services 1.3 March CTP I got the message “Please wait while the installer finishes determining your disk space requirements” I found a blog post on it where Corey Roth describes how to manually extract the MSI file and install it. This got me to thinking. I moved the CTP from my desktop to the root of the drive and ran it from there — it ran fine. Seems like it might be a path length issue.

Don’t mess with SharePoint’s Site Property

It’s been a while since I’ve stumbled across a defect in SharePoint so I was about due. (I’m not saying that it’s a buggy product — I’m saying that you do what I do you just get used to finding defects.) This one was interesting. SharePoint has what are called dynamic scopes (‘This Site’ and ‘This List’) and for this particular client they didn’t work. They never returned results. You could search with a different scopes and you would find the content so I knew it was being crawled correctly. However, when I would search with one of the dynamic scopes, no dice. What made it more fun is that it was only one of the two SSPs on the farm that had the problem — so we knew it wasn’t corrupt binaries.

After a ton of research and some good work by escalation engineering we realized that the ‘Site’ managed property in the SSP had been deleted and recreated. Oops. That’s bad. Somewhere SharePoint relies on that not happening (generally because they refer to the property via a well known ID number instead of its name.) The issue has been reported but it’s not going to get fixed. The net result is that we get to recreate the SSP. That wouldn’t be so bad except that this customer has targeted content. So? Well, audiences may have friendly names but what’s stored in the pages and web parts for targeting is the GUID of the audience — and when you create an audience, you can’t specify the GUID — even through the API. Gary Lapointe has some STSADM command extensions that will allow you to import and export audiences. That’s a good start but that still means coming up with some code to enumerate all of the pages and all of the web parts on the pages looking for targeting — and changing GUIDs if they are. The good news is that the field isn’t really protected so you can do the replacement pretty easily. The bad news is that no one has created a tool to walk all of the targeting in a web (or farm) and make those GUID changes. (It would be quite useful.) We’ll probably manually repair the targeting because it will take us longer to build and test a tool than to do it by hand…

Search Center vs. Search Center Lite

The topic of the week appears to be the difference between the two Search Centers in SharePoint. One search center, Search Center Lite — which shows up in the user interface as Search Center, is created by default for you if create a Collaboration Portal. (It’s on /search.) The other search center, Search Center with Tabs, only shows up if you activate the Office SharePoint Server Standard Site Collection features (See below)

Once you’ve activated the feature your create site page will include the full list of templates including: Document Center, Records Center, Personalization Site, Site Directory, Report Center, Search Center with Tabs, and Search Center (See below)

If your create site only has Records Center, Report Center, and Search center — you don’t have the feature activated (see below)

So what’s the big deal? The differences aren’t that big, are they? The standard search center (Search Center Lite) shows:

Where the Search Center with Tabs shows:

Basically tabs. Who cares? Well if you have a set of complex customizations and want people to be able to search in different ways — then you care. Search Center with Tabs uses the publishing features (WCM) in SharePoint to allow you to create your own pages with different search configurations on them.

Recent Posts

Public Speaking