Archive

Archive for the ‘development’ Category

Sharepoint Versioning – Gotcha 2

June 10th, 2009 No comments

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()

 

Categories: development, Sharepoint Tags:

SPQuery DateTime query and the Time ignored

December 11th, 2008 2 comments

The U2U CAML Editor is great but it does mean you don’t take the time to learn CAML properly, eh-hum!

My queries were going very wrong and I couldn’t figure out why, so I pasted them into the CAML query tool and tested it and noticed it didn’t matter what time I set in my query it was ignored.  The CAML editor doesn’t have an option to include time values, so I could not tell what was needed to make it work.

I found this blog post http://ucsharp.wordpress.com/2007/10/11/9/.

It basically tells you that you need to tell the Query to use the timevalues and not to ignore them, this particular part of the query needs that little bit extra

<Value Type=”DateTime” IncludeTimeValue=’TRUE’>2008-12-11T16:07:00</Value>

Go test it in the CAML creator tool and see for yourself!

Thanks ucsharp.

It would seem that CAML girl looks for posts on her great tool, (I would not presume that she reads my blog!), did I miss something ? if not can you tweak a new version to have an includetimevalue checkbox (it shows people its possible)

P.S. Whilst you at it can you add

a Recently opened sites bit too

Remember user creds (securley stored in isolated storage perhaps)

I should shut up really as you can’t complain about something so handy that’s so free.

Technorati Tags: ,,
Categories: development, Sharepoint Tags:

WSS3, Workflow Hint

December 10th, 2008 No comments

When exploring workflow you might want to create a bit of code and have it execute and fire of the debugger to investigate all the properties your expecting are there.

Hint.  In your Execute Code block where you write the code to check stuff out, its worthwhile placing this BEFORE any timeout events you have in your workflow, here I am sitting waiting for the next 60 minutes before my event fires.

In fact I’m finding that a call to Debugger.Break()  doesn’t start the debugger after a timer has started, how queer normally this works on everything.

Needless to say I’m making a quick change to my workflow order for now.

 

Technorati Tags: ,,,
Categories: development, Sharepoint Tags:

Using a ListViewWebPart for Search Results

December 5th, 2008 4 comments

I have had to try and create a Search page that displays its result set in the style of a ListViewWebPart.  This has proven quite tricky.

After a lot of Searching I found various articles on using SPQuery and then the List.RenderAsHtml(Query) to achieve this.  However I found a rather large problem with this method, whilst it queries what I want it to the resulting HTML looks nice but does not do any kind of paging also whilst the sort and filter  drop downs appear at the top of the columns, they don’t actually do any sorting or filtering.

Now that was completely unacceptable.

Read more…

Ajax DeepZoom

November 25th, 2008 1 comment

MS Live Labs have been playing with the “deepzoom” technology, and for those without silverlight installed, you naughty people, you can now create a deepzoom image that can be navigated in Javascript, cool eh ? They call it Seadragon Ajax after the original technology name before the marketing people got to it ;-) (Bill Crow pointed this out to me as I had mis-named it Ajax DeepZoom, The title remains the same as it gets the poitn acros to anyone not aware of the Seadragon name).

The link to the post detailing this explains pretty much what I just did then you can go and embed the Image.  Now its a little tricker than they explain so here is some more details.

Read more…

Categories: ajax, development, Silverlight Tags:

Focus on that Bug – TFS

November 21st, 2008 No comments

image One problem I find since I started using TFS is I don’t focus on one bug, I often solve several at a time sometimes interconnected sometimes not, often down to which one I feel like fixing as that, for me, yields better results.  However its not always the best way, especially when working with others.  Most of the time I don’t play with others so it works for me.

But I have to train myself to use this thing (TFS) better and part of that is pick a bug/task and stick to it.

So I came up with the simplest of things to help with this.  Visual Studio windows.

Simply pick the bug your working on select the code and create a new horizontal tab group and drag it to the top till you only see the tile of the task in yellow. 

Simple but effective, well not that effective cos here I am blogging it instead of coding.

Categories: development Tags:

WSS 3 / MOSS Creating Views in CAML (List Definition)

November 6th, 2008 No comments

I have been creating custom Lists in CAML for deployment by features.  As you do.  I found out a few things that might be of help when you are creating them yourselves.

I am  Assuming that you now how to create a list template and know what goes in a schema.xml to a point.

Concentrating solely on views here I found out this.

If you have a List View WebPArt you need one of these types of views, if you don’t LVWP don’t work.

<View BaseViewID="0" Type="HTML">….</View>

Careful of BaseViewIDs being the same.

<View DefaultView="TRUE" SetupPath="pages\viewpage.aspx" Type="HTML" DisplayName="Summary" Url="Summary.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
            ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">

<View SetupPath="pages\viewpage.aspx" Type="HTML" DisplayName="Summary"  Url="Summary.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
            ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">

Notice that the BaseViewID’s, that wonderful field that’s barely documented, if they are both the same number then you might get problems.  I can’t explain why, but In my views I created the second view had a different Query but was ignored when created and it copied the first views query.  When I changed the BaseViewID=2 on the second view everything worked.

Is that the right thing to do ? I can’t say I’m only commenting on what I have observed.

Don’t do this

<View DefaultView="TRUE" SetupPath="pages\viewpage.aspx" Type="HTML" DisplayName="Summary" Url="Summary.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
            ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">

<View DefaultView="TRUE" SetupPath="pages\viewpage.aspx" Type="HTML" DisplayName="Summary"  Url="Summary.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
            ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">

If you forget when you cut and paste if you have two default views in the "Lists" page it shows up twice, its not really there twice but looks like it is.  You may not notice till too late with this one.

 

Categories: development, Sharepoint Tags:

Handy WSS / MOSS Debugging hint

November 6th, 2008 No comments

I’ve just had a chat with a colleague who was struggling to make one of our installers work.  Which reminded me of the WSS course with Todd Bleeker I was on regarding debugging and quickly trying to debug or attach to stsadm and Studio just isn’t playing.

Read more…

Categories: development, Sharepoint Tags:

My SPQuery doesn’t work

October 23rd, 2008 3 comments

I had my first tortuous experience with SPQuery today and found out a few things.  Now this isn’t a full explanation of SPQuery, I suggest Ted’s book for that. But there is the answer to a couple of gotcha’ s that can truip you up

Read more…

Categories: development, Sharepoint Tags:

Some Tools a .NET developer should not be without

May 2nd, 2008 No comments

Recently I had the joy of trying to work with some Web Services from a 3rd party system not written in .NET.  In this age of full understanding of XML and Interoperability and Basic Profile 1.1 compliance  this was of course completely easy.

NOT!!!!

This was a complete pain in the neck.  I had problems at every turn.  Our existing .NET web service that provides a similar service, soon to be retired though, was written in .NET 1.1. So I just wanted to modify it rather than do an upgrade.  The remote system used  Http1.1 Chunked mode.  .NET 1.1 does not handle this.  So .NET 2.0 here I come (I know I know that’s still legacy !).

Read more…

Categories: development Tags: