Hands up if you hate STP’s

Is it me ?  Have I missed something ? Are STP’s the best thing on the planet for quickly creating SharePoint sites ?

Or is it as I believe the biggest pain in the backside for SharePoint developers to pick up someone else’s SharePoint project to make changes to the site definition pages only to discover they were hacked together in the interface saved as an STP and included in your project.

This is now the case for me on two of my inherited projects, I hate them.  Now I know that if you create standard site templates with an onet etc, once created, there are elements of the definition that are now content and would have be be manipulated via the API to change them (or interface). But consider if you have a problem and are searching in a HUGE project for where your specific list might be or other such content, can you find in in Studio by searching ? No you can’t cos it’s all cabbed up in a file.

So my advice to anyone even considering using STP’s, think again are you doing it cos it’s quick and your a contractor soon to leave the company anyway so what the hell, or are you a developer who might have to make changes and maintain your project.  Seriously think twice, is this the best way to develop this solution, is there some advantage to an STP over a site def ? think before you start hacking away.

Technorati Tags: ,,
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Sharepoint Versioning - Gotcha 2

I’ve had a right game with this Sharepoint Versioning problem.

Now those of you used to writing .NET but maybe not SharePoint will be used to having AssemblyVersion attributes set in the AssemblyInfo.cs files.

This is something I took into my last SharePoint application for wss3.  Now in SharePoint 2003 I got used to not setting the version number but it slipped my mind for WSS 3.0.

My particular problem was I had some ItemAdding/Updating List events.  These were configured to fire in one of my Assemblies. My build server would automatically increment version numbers in AssemblyInfo.cs and in all associated .xml files in the features, very clever I thought at the time.  Now I needed to update this assembly and modify some code in these events.

I made those changes and installed it and all of a sudden none of the events were firing at all.

This is because when a list is created the EventReceiver details of the feature are not read from the XML file but are stored against the List in the content database.  This makes some sense as if you update the list template then you can update the EventReceivers as well and have different versions of a list definition with different handlers.

In my experience it’s more likely that you will want to modify all the existing lists and template as your probably implementing a fix, especially if using SharePoint as an app platform.

So how to fix my now rogue ItemReceivers.  I could do some fancy coding in Feature activations etc, but I really don’t want to go there and have code left lying about for what will essentially be a one time fix.

To the rescue PowerShell.  Luckily for me we use PowerShell so I  can create a post update installation script that runs just this once.

Here is the gist of it.

###############################################################
# Validate args
###############################################################

    if ($args.Length -ne 1 -or $args[0] -eq "-?")
    {
        Write-Host "Usage: .\FixIt.ps1 <SiteUrl>";
        return;
    }
    $SiteUrl = $args[0];
    cls

###############################################################
#Get Base Objects
###############################################################

    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    $site = New-Object Microsoft.SharePoint.SPSite $SiteUrl
    $web = $site.RootWeb
    $lists=$web.Lists

###############################################################
#Change List Event Receivers
###############################################################

$list=$lists["BrokenList"]

#I happen to know there are only 4 Receivers really I should use the count
#One of them is named wrong as well hence the 3 cases
#(in the real version I fixed that too)
#You need to count backwards as it deletes and re-inserts so a foreach wont #work.

for ($i=3;$i -ge 0;$i–)
{
    $er=$list.EventReceivers[$i]
    switch($er.Name)
    {
        "BinaryJam BrokenList Receiver ItemUpdating"
        { 
            $er.Assembly="BinaryJam.MySharePointApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1111111111111111"
            $er.Update()
        }
        "BinaryJam BrokenList Receiver ItemAdded"
        {
            $er.Assembly="BinaryJam.MySharePointApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1111111111111111"
            $er.Update()
        }
        "BinaryJam BrokenList Receiver ItemAdding"
        {
            $er.Assembly="BinaryJam.MySharePointApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1111111111111111"
            $er.Update()
        }
    }
}

$list.Update()

 

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

WSS 3 – AssemblyVersion - Gotcha

Well what a great gotcha I had today.  I have a WSS application you know custom list templates, event receivers web parts, everything you can think of except workflow.

So I have an upgrade for this, its a new dll and feature files.  I use a build server that can automatically update the AssemblyVersion and automatically edit the dwp aspx ascx files etc to set the version number of the build, its very slick.

Forgetting one thing.  SharePoint has never liked Version numbers. So I applied the update and my webpart fails with safe control errors. 

I forgot when you add the webparts it copies the dwp complete with version number into the content database and I just uninstalled that DLL. DOH! 

After figuring this out with the help of Captain Literal.Net, I stopped my build auto updating the versions and grepping the files etc.  It still marks the file version number to help the support guys but not the AssemblyInfo DLL versions now.

According to the Cap’n its not just the webpart dwp’s but lots of other features (small F)  that don’t like changes to AssemblyVersions, in fact there is code in SharePoint that deliberately IGNORES policy files.

So there you have it, again Versioning is a bit dodge in Scarepoint. Choose when to do it and know what the effects will be.  And don’t forget to take those *’s  (stars) out of the AssemblyVersion attributes and FIX it to 1.0.0.0.

However you can change the Feature.XML file and change the Feature versions this doesn’t have any effect that we have noticed.

Im thinking of throwing together a feature that reads all installed features (hidden or not) and displays the details like title, description and version.

Technorati Tags: ,,
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

SPUtility.SendEmail Function truncates text

It would appear that

SPUtility.SendEmail function truncates the body of the email.   I’m having this problem and so is someone else (here).

Not much more to add here, if anyone knows why or knows of a setting, love to here it

(please don’t post a workaround solution using .Net objects we can all figure that one out for ourselves thanks.)

Word of the day.

Damn.

Technorati Tags: ,
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

WSS - CAML and XSD schemas

If you developing List Schemas drop what your doing and go and install this.

CAML.NET.Intellisense

It is an expanded wss.xsd file containing a lot of descriptions and possible default values. When coding in Visual Studio using this will alter the schema defs and give you uber intellisense on your schema files.

If you already use wss.xsd in Visual Studio you will need to remove your reference.

Now if you forgot how you did that then the usual way I found of configuring it was to goto

C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas

(or equivalent for your platform)

An to create a file called wsscatalog.xml, you may have called it something else but it contains xml like this

   1: <SchemaCatalog xmlns="http://schemas.microsoft.com/xsd/catalog">
   2:   <Schema href="%CommonProgramFiles%/Microsoft Shared/web server extensions/12/TEMPLATE/XML/wss.xsd"
   3:           targetNamespace="http://schemas.microsoft.com/sharepoint/" />
   4: </SchemaCatalog>

 

So go and remove that before installing this version as it won’t remove it for you and Studio can fight over things if you don’t or just not work at all as was my case.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

WSS - ListView / Schema.xml and Embedding Javascript

Many of you out there in SharePoint land will from time to time have the need to edit a list definitions schema.xml file to create your custom list.  You may also have need to edit the List View in that schema file to create a different kind of view, one not possible to create by the SharePoint UI.

I have had need to do this recently.  I needed a List View that highlighted expired items or tickets in my list.  It needed to make them go red.

Now you might think that’s easy enough create a calculated field that does date maths on the date you have in the list item and the current date that gives basically 1 or 0 for expired or not.  Well you’d be wrong.  You see you can’t use [Today] or anything like it in a calculated field the list wants fixed not dynamic values in it and will not allow Dynamic values, think about it, it would seriously effect performance.

Rather than create a DataViewWebPart based on my list view and edit that to death, it did not give me exactly what I required, even with editing, and the time to do it would be longer for me to achieve.  I decided to embed Javascript code into my ListView.

Click to continue reading “WSS - ListView / Schema.xml and Embedding Javascript”

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

WSS SharePoint and Powershell

This is just a quick note to ask the question

Are you using Powershell when developing your WSS application ?

Cos if your not your missing a trick.

Click to continue reading “WSS SharePoint and Powershell”

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Custom Forms in WSS

This isn’t going to be an essay or guide on how to do this, it’s just I’ve been doing this and had the following problem.

I have custom forms as the default ones don’t cut it, they don’t cut it cos of hierarchical dependencies in dropdown lists.  Now I don’t have the time to do lots of ajax or try to fight to get some ajax framework approved by, whoever, to use in my product.  So I’m using good old fashioned postbacks.

But postbacks on large forms are annoying and you need to return to the same scroll position.

Since .Net 2.0 there has been built in the MaintainScrollPositionOnPostBack directive for the @Page, something that’s as new to me as .net 2.0 (I was doing SAP for a bit for fun and a break remember ?) .

You can use this in your custom forms to.

Now I don’t know how much custom forms stuff you may have done, but I want CodeBehind in mine and struggled to get any code-behind, so I have custom forms that host another user control that I do have code-behind in.

In that Code I use the following

this.Page.Master.Page.MaintainScrollPositionOnPostBack = true;

 

Now if you have a custom master page then you can use that @Page directive instead, if your using the default on then you can use this instead.

Works a treat.

Technorati Tags: ,
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Songsmith

In case you have not heard, Microsoft Research have come up with some song writing software.  It’s called Songsmith.

The idea behind it is that you make up a tune in your head then sing it into songsmith.  First you pick a music style and then a tempo and then sing away.  Once recorded  the software will analyse your song and the notes you sang,( hopefully you sang them in tune I don’t think it cleverly pitch shifts your voice, but I may be wrong ) and then it will create a musical accompaniment in the style you selected.

Now I know what your thinking but the MS web site states

"The samples you hear in Songsmith aren’t toy sounds… they’re a high-powered general MIDI set from Garritan, one of the biggest names in the industry"

With resources like this how can it fail ?

Now it’s not aimed at pros but to give anyone a chance to write a song, well my son is seven and is not a musician, yet, he hasn’t displayed any interest in that area, until recently, but even he hears that the stuff this thing produces is absolute pap.  It can’t even compose a good jingle, take a listen to the MS videos and cringe.

Where the genius of Songsmith lies, and this was totally unintentional I’m sure, was the sheer comedy value provided when you take songs you know and feed the vocals into Songsmith and have it re-write the original into the dreadful "early eighties, cheap casiotone" sounding affair it produces.

Youtube is starting to accumulate examples of Songsmith Massacres.  Radio heads Creep, britney’s Toxic, battery by metallica and loads more.  

So I wouldn’t bother getting Songsmith but go take a look on youtube and laugh your pants off on the utter tosh it produces.

 

Technorati Tags:
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
Posted in Misc. No Comments »

Being Human

Last night with tons of advertising and announcements (I don’t think), the first series of Being Human snuck its way onto the schedules.

Well done BBC for finally getting there with this series.

I’d love to tell you how good or bad it was but due to the marvelous media campaign I missed it, I stumbled across it half way through the episode where I managed to see all the characters and the new actors playing two of them. 

Like I say I missed it so I wonder how the new actors will fit, if at all, the characters we were introduced to.  I do have doubts about the ghost, far to attractive and very removed from the pilot character, who I absolutely loved.  Is this a real improvement to help the story or just eye candy to keep part of the male audience who struggle with plots engaged.  I don’t doubt the young ladies ability she seemed very good but its not the funny, kooky plain northern lass obsessed with making tea entrenched in routine to cope with her death and being tied to the house.

Anyone who did watch, what do you think ? Does it measure up to the pilot ?

Anyway, I can be thankful for iPlayer and will watch all of it tonight.

Technorati Tags:
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
WordPress Loves AJAX