Wednesday, December 16, 2009

ErrorWebPart when loading a CQWP using the object model

When you are using the object model from a console or windows application to load web parts, you will notice that the CQWP (content query web part) instances all show up as "ErrorWebPart", and do not allow changing any of the web part's settings.

This is because when you load the web part, the web part code tries to access all kinds of data from it's context. Since you are loading the web part without a context (that is, from a windows application instead of a web application) the web part fails to get the context, and gets reported as an ErrorWebPart, when infact it works well if you look at it on the web interface.

I have yet to find a solution for this, but one workaround that works is to move your code to a web page, in the "_layouts" folder. This allows the code to run withing the site's context, and so accessing the web part does not cause it to report ErrorWebPart.

Update: It has been brought to my attention by a reader that Sandeep has a workaround for this:

Tuesday, November 24, 2009

SharePoint 2010 - virtual vs non virtual

This has been a very bad week - since the Beta of SharePoint 2010 came out I have been trying to install it and set up a demo environment for developers on my laptop - without much success. Since 2010 requires 64 bit, this ruled out using VPC, and since I don't like using 2008 as the host on my laptop, this meant I had two choices: virtualize with a non-MS solution that allows 64bit clients (virtualbox by sun or vmware) or install sharepoint directly on my windows 7 host - which means I would have Beta software running on my production laptop.

I chose to try virtualbox - and failed twice. First I installed windows 2008r2, and during my presentation to the user group last week it was a disaster - the site kept crashing with unknown error, nothing in the logs and nothing working.

Then I installed a fresh install of windows 2008 with all service packs in the virtual environment - and again installed sharepoint. Again - same symptoms - the site crashes and works SLOWLY.

Finally today I gave up and installed the entire 2010 beta system on my laptop itself - on the windows 7. Apart from the fact that I had to download and install the prerequisites manually (on the server it did it automatically for me) and apart from the fact that I didn't follow the instructions very well (I used 7-zip to extract the .exe file so I can change the config.xml file - which put all files in the one folder - losing the hierarchy. it turns out this gives a "wrong language" error (I forget the exact syntax)) the installation went quickly and easily - so now I have a stand alone windows 7 with sharepoint 2010 and office 2010 and VS2010.

I will keep updating when I have time to play with all of the above...

Modified date stopped working...

So here is the scenario - I had a piece of code in a feature that changed the title of the built-in site column "Date Modified" to...well..."Date Modified". As you can see, the code looks a bit useless, but someone thought it would be useful, so there it was. Next thing I know, the date modified field stopped working in out of the box document libraries. You would edit a document or its properties and the modification date would be the same as the creation date. This would even show in the version history...

Solution - I had to write a small piece of code that would set the SchemaXml property of the site column to the default. It turns out that if you change the field using code (like SPField.Title="Date Modified"; SPField.Update()) then sharepoint removes some very important tags from the schemaxml property of the field - which causes it to break. To fix I just copied over the SchemaXml property from a site column in a brand new site that was not damaged.

Code sample:



using (SPSite site = new SPSite(txtSite.Text))


using (SPWeb web = site.OpenWeb())


SPField field = web.Fields.GetField(txtField.Text);

if (field != null)


field.SchemaXml = txtSchema.Text;


MessageBox.Show("Operation completed successfuly");




MessageBox.Show("Field '" + txtField.Text + "' could not be found in the site columns in" + Environment.NewLine+ "'" + txtSite.Text + "'");



} } catch (Exception ex)

{MessageBox.Show("An error has occured : " + Environment.NewLine + ex.Message);}

Sample schema: <Field ID="{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}" ColName="tp_Modified" RowOrdinal="0" ReadOnly="TRUE" Type="DateTime" Name="Modified" DisplayName="Date Modified" StorageTZ="TRUE" SourceID="" StaticName="Modified" FromBaseType="TRUE"/>

Thursday, November 12, 2009

Event handlers in SharePoint 2010

This is too many more options - take a look at the visual studio 2010 wizard for creating an event handler - it is more than just list items...

I really like the web events - these will be very useful and will allow creating complex solutions without site definitions.

As soon as the beta is out I will write some samples!

Thursday, October 22, 2009

Closing thoughts from the SharePoint conference

I am sitting in the last session, and I have to admit- I am a little bit afraid of SharePoint 2010. There is just so much more, that it makes the step from SharePoint 2003 to 2007 seem small in comparison. I think we should thank the SharePoint product team for an enormous effort to get all this new stuff in - and give us some very complex stuff to work with.

I am looking forward to doing search solutions, writing visual web parts, developing better event handlers (post synchronous events!), designing in sharepoint designer and then moving the design to visual studio and more and more and more.

If you get access to the presentation videos - make sure you listen to Mike Ammerlaan's presentation titled "Architecture guidance for building applications in SharePoint 2010" - not sure how much of that will be reviewed during the beta period (starting next month) but this was THE best and most important presentation in the conference - giving us thumb rules of what to use when, and some key pointers to making decisions on what to use in different development scenarios. Thanks Mike!

Finally, there are things I am dissapointed with - like a continued lack of support for custom fields in office, and no exciting new field controls. But the good overweighs the bad. I will have a think about what I have seen in the next two weeks, and then start blogging again - from TechEd Europe.

For now - I am going to see the grand canyon, visit Munich, and have a week's vacation in Israel with my family. Be patient, and more posts will come in tow to three weeks. If you are coming to TechED and want to chat - see you in Berlin in the Ask The Experts booth!

Wednesday, October 21, 2009

What I like and dont like about the new BDC (the BCS)

To get one thing clear - when BDC came in MOSS2007 I was very excited about it. I really thought it was great...until I had to do a real life project with it.

No, I am not talking about the pains I went through to create an application definition (this was before the BDC metaman or the tool that Microsoft released a bit later) - I am talking about how the BDC integration to sharepoint was so limited.

Every single customer who had a problem that I wanted to solve using BDC had the exact same requirements that I couldnt give them using BDC:

  1. We want it to work in office
  2. We want it to be a multiple item selection

There is no way in MOSS2007 to achieve both in BDC. You can develop a custom field type that will allow multiple selections from BDC information, but you cannot use a custom field type in Office. And the built in BDC column type only allows single selection.

That makes me sad.

In 2010, the "BCS" is much improved. It makes me even more excited about what I can do with it. It has "external lists" - which are fancy web parts that make the BDC data appear to be as if it is in a sharepoint list- including filtering, adding items, editing items and so on (not full functionality of a list though). There are two designers for the applications - no more XML! just use sharepoint designer or visual studio and create application definitions easily. Heck, in VS2010 you can create the connector to the LOB system in the same project as the application definition model - and refactor stuff later. This is EXCITING and GREAT stuff. Not to mention the object model, the (much) better support for item level security and so on.

But it still does not solve the problem I described above - the BCS column type is still a single lookup.

I was hoping that Microsoft would introduce better support for custom field types in Office 2010, but that is not happening either, so there is no oppertunity for me to develop a custom code to do that.

This makes me even sadder.

Can everyone please join me in asking Microsoft to

  1. Release a better BCS field type before RTM of as part of SP1 and make BCS perfect
  2. Redesign how custom fields are supported in office applications for SharePoint 15

Meanwhile, I will enjoy the cool new features.

Tuesday, October 20, 2009

Joke of the day from SharePoint conference 2009

quote: "if I don't need to dispose objects in the client object model, and it can do whatever you can do in the server object model, I am going to use it on the server!"

Ishai comments: good joke - do not take seriously please...

Update: it turns out you do need to dispose of them (when using them in .Net applications)

Upgrading custom developed solutions to SharePoint 2010

I am sitting in the presentation by KwizCom who are telling about their expirience with upgrading their products and web parts to SharePoint 2010. This is exactly the kind of session I came here to hear - get real life expirience from real life senarios.

Shai Petel is a huge expert in SharePoint development - his presenation is focused on what you need to do Today to make your current projects be ready for the upgrade.

He suggests to train the developers to use Ajax, JSON, silverlight, visual user controls (which I have to admit - it has been ages since I developed a web interface with a designer!).

He also suggests that if you want your solution to be hosted in the cloud, try to limit the solution scope to a site collection level. He did not explain, but I am guessing this is because of sandboxing restrictions.

Shai also encourages you to make sure you use the ASP.NET web part class for your web parts. He explains that the WSS web part class is supported for backward compatability, but does not recommend it.

Shai also recommends working on windows 2008 R2 and running hyper-v machines as your development environment. I don't agree - windows 7 is a (almost) perfect operating system, you can run moss on it, and using Sun VirtualBox (free, and open source) you can create 64bit virtual machines - and from my expirience on my laptop - win2008 just doesnt run as fast.

Now to upgrading a solution. Shai stresses that you should use the same namespacec and assembly evidence - this will allow sharepoint to recognise your solution during the upgrade.

Shai talked about upgrading his "sharepoint list forms extensions" - he showed how the solution looked like in 2007 - both in the screen (new links in list settings and in list forms) and in the code - showing a solution (connected to source safe? who uses source safe these days? or maybe I misread what I was looking at?). He then showed what he added in the 2010 version for the same solution - explaining how in 2007 they couldnt use WSP packages for the solution (due to limitations of the WSP infrastructure) and how now they are using WSP (due to improvements - mostly around version management - see further information below).

Shai opened a new empty VS2010 project, and built the structure for the project that you want, and then migrated his old code into the new project. Then, using a designer in visual studio, defined what features (from the old solution) should be deployed by the solution. He suggested it takes up to 4 hours to do that on a big and complex project.

He then showed how he added new code (or, rather, XML definitions) to replace old custom actions with new ones that would put the custom actions he had in the tool bars into the ribbon instead.

At this point Shai's Virtual machine crashed (working on pre-beta version - this is happening to many speakers here I guess. this is the second presentation in a row that I see this happening to) so he continued with his powerpoint and concluded that with a project that DIDNT use VSEwss (visual studio extensions for wss3) is pretty simple - create new project in VS2010, import existing files, set up the features (using a designer) and add what ever you need.

With projects that were created using VSeWSS need to be opened using a tool that comes with visual studio 2010.

To upgrade an existing WSP package - there is an import wizard in VS2010 that allows you to select which part of the solution you want to import, and it imports it into a new VS2010 project - all except the code. So it does give you the feautres and images and so on, and puts them in the new project structure that VS2010 needs.

About versioning support in packaged solutions - Shai explained that this was missing in 2007 - and is now available. I had many headaches with WSP packages versioning - it is very hard to mark a version number in a package - you have to keep updating a web.config file to make sure sharepoint uses the new version if you change the version of the dll. Shai suggested the same method I have been using - store the version number on a file that is deployed with the package instead. An "about" page can show the user what version is deployed on the server.

Shai then explained that he recommends deploying solution resources into a folder marked with the version number - for example : "_layouts/mysolution2.0.0.1" - this will make sure the solution can be hosted - and then upgraded just for one customer that uses the server, while other customers use the old version - the resource files were not overwritten (remember the assembly in such scenarios is sandboxed - so not in the GAC but rather in SQL and is unique per site collection - which allows this kind of trick).

The new user interface for managing solutions in a site collection (sandbox) will show you if there is an upgrade available for a solution. Us developers can specify that a solution can be updated, and then sharepoint will show that to the users. I expected something more sophisticated - something like how most applications today do upgrades, but I need to get my hands on this feature before I can comment on it fully.

To summarize - good presenation (if a bit rushed and mis-titled) and exciting things ahead!

SharePoint 2010 Web Parts and WiKi pages

Wiki web parts - are new and do not have web part zones. You can add the web part in the text. This will allow us to give an option for the end users to create a page without an underlying page layout.

This works with hidden zones - which is where the web parts are actually stored but the location of the web part is marked in the wiki content using place holders. During rendering the webpart contents are moved to the in line location after rendering. Maurice just showed what happens if you retract a solution that had the web part that was added to a wiki page. The page was then refreshed - and no crash - the web part just disappeared from the page. however, when you go to the maintnance page (add a "?contents=1" to the page url) you can see there is an "error web part" on the page. It still doesnt tell you what that web part used to be - which is something I expected Microsoft to improve from 2007.

Also, Maurice showed a bug that is with the current version and he is not sure if it is going to be fixed - when you delete an error web part, the div with the web part ID remains in the content of the wiki page - not visible, but it is making the page heavier, and messier.

To add a web part to wiki pages using code, you add the web part as usual (using the web part manager) and then you change the text for the wiki to include a div that links to the GUID of the web part.

SharePoint 2010 - No more reasons for WSS web parts

I am now in the session presented by Maurice Prather - a web part guru who used to be in Microsoft working on sharepoint in the past. He is now discussing my favorite topic- how to develop and deploy web parts in sharepoint 2010. News - WSS web part are phassed out. How is this different than 2007? they already said that in the past - the framework still gives the wss web part the same benefits - caching, better communication options and WSPC.

How is it possible to stop using the WSS web part class? the answer is that in web parts will now have more functionality available to them such as:

  1. Versioning of web parts in pages - if you make a change in a web part in a page - and then revert the page to old version of the page, the web part will be versioned with the page.
  2. Ajax
  3. Client object model
  4. Cross site scripting safeguards
  5. sandboxed solutions (I wrote about that yesterday)

So I don't see a solution for caching - you should implement the native ASP.NET cache.

WPSC will still exist for WSS web parts - so you can still do client side collections with it. But - now that you can do it with ajax, there is no reason why to use a WSS web part.

Monday, October 19, 2009

Training SharePoint 2010 Developers

And my friend Shay Petel is asking a serious question - when doing sharepoint training - do you start with sandboxed solutions so that you can use them during the course, or do you only get to them after teaching people how to develop web parts and other solutions using the standard WSP deployment mechanism? This is a big question that us trainers need to tackle. This whole developer training for sharepoint is going to blow out of proportion for us in the next year - from being a 5 day course for sharepoint 2007, I think we are going to need a 10 day course in 2010, and that may not be enough.
That said, I think that things like visual web part development significantly reduce the training time required - since developers will not have a problem with the learning curve any more...

SharePoin 2010 - Sanboxed solutions

Thanks to Scott Hillier the speaker

Runs in a separate process, added to a site collection level gallery.

User code service: SPUCHostService.exe
Worker process : the actual process SPUCWorderProcess
Proxy : SPUCWorkerProcessProxy - exposing a subset of the sharepoint services. If not exposed, you cannot use it in the sandboxed solutions. This includes all the enterprise stuff - including BCS and search and so on. So do not plan to use sandbox with those objects.

Remember - anything in a sandbox will run a lot slower than if it is not. So sandboxing has several limitations - the one mentioned above (some assemblies are not available if you are sandboxing) and the significant slowdown of the solution. This means that while deploying solutions to hosted web sites will be simpler, it also means you will slow the environment down.

I also like the soution validation - where you can write conditions in code that will be checked when the solution is uploaded - and then allow or prevent the solution from being deployed.

Resource monitoring - you are getting information about CPU, Memory, SQL, Exceptions, critical errors, hanlders, threads and more.

Workflows & Site Templates and debugging projects in SP2010 and VS2010

I like the option to design workflows in Visio, load them and design them further in SharePoint Designer 2010 and then export that into a Visual Studio project (since only VS integrates with source control).

You can save a site as template - which gives you a WSP (say good bye to STP) file that has all the objects. Visual studio then can load that WSP and show you designers to edit the WSP.

When you debug a project using F5, only the project marked as startup gets deployed. The other projects in the solution do not get deployed unless you manually deploy them. And by "manually" I mean you right click them and select deploy (like with WSP builder!).

Visual studio - allows you to package, retract per project, has a special sharepoint browser that shows you the objects in a sharepoint site - much better integration.

Highlights - new in SharePoint 2010 for Developmers?

  • [Like]Web Part developer dashboard (will require sts command to be activated in the public beta) . As I said, it showss what SQL queries were executed, and you can click on the query to get more information of what was going on.
  • [Like]Visual web part development
  • [Like]Sandboxed solutions - you can upload a WSP to sharepoint - no STSADM command. it sits in the database - and someone with privilages can than use the code in the WSP - but it runs in a sandbox while sharepoint monitors the resources that it uses. Nothing is deployed to the file system (so you can version items properly, and you dont have to worry about multiple front end servers). Instead of using the sharepoint dll, the sandboxed solutions use a proxy dll. You can get logs from the proxy service that look at what the solution does.
  • [Like]debug web parts - when you "run" the solution, it automatically opens the "create page" dialog in the site you designated, so you can create a new page, and add the web part to it. Breakpoints will automatically break (because the code gets attached correctly to the processes). To do this, the VS solution is actually built and deployed before the debugging.
  • [Like]Linq for sharepoint - simply add a reference to the sharepoint linq dll, and
  • [Like].webpart files are the same format as 2007
  • Bussiness Connectivity Services - replaces the BDC.
    • [Like]This will have read\write.
    • [Don't Like]The sharepoint field types that expose the information were not upgraded, which means that a BCS column still will not allow multiselect.
    • [Like]Designer for the application definition in both VS2010 and SharePoint Designer 2010
  • [Like]Relationships between lists - you can prevent deletions or cause cascading deletions. However, no cascading inserts... but I guess this is where custom solutions come in.
  • Lookups to multiple columns
  • [Like]List query throttling - preventing views from showing too many items - this will be dynamic - each view evaluates on the fly and if a view is going to display more than a specific amount it can be blocked.
  • [Like]All views are XSLT views - not CAML (CAML can still be used) - this will make it a lot simpler to customize list definitions!
  • [Like]column validation - you have a new setting for columns, where you can write a forumla (excel style) and a message to show the user if the formal does not evaluate. FANSTATIC. Shame it only supports cecrtain types of fields.
  • [Like]REST API and client object model- need I say more? Client object model will allow you to connect to a site using a "ClientContext" object, that is instanciated with a site url parameter. REST, in case you don't know, allows you to get information from sharepoint using just URL's - and you get back an XML. So no more developing web services, now your client side code (javascript or different clients) can get the information just by building a URL, performing a http request to it, and getting back XML of the results. I have talked about this in the past in the blog about how you can do this in sharepoint 2007 - specifically how to get list and site information for an infopath form without using web services (there is a file called owssvr.dll in the _vti_bin virtual folder that gets you information from lists and sites), but in 2010 it will be a lot better integrated (and documented), not to mention the javascripting will have proxies built in and development will be easier. Note - when using the REST API using a .net application do not forget to set the credentials to the REST object. I wish MS would instantiate the object with the default credentials from the cache - that would save some lines.
  • [Like]After Synchrounous events in the event handlers! yay!
  • [Like]site scoped events
  • [Like]Workflows - integration with Visio (interesting...)
  • [Like]Upgrading code - MS provides assembly redirect for most of the sharepoint dll machines. This means that code that you wrote in 2007 has a good chance of working in 2010! This enables upgrades of a portal to be more smooth. It is still unclear to me how custom site definitions will be migrated.
  • Application life cycle management - generally better with TFS - no other mention of what is better so far.

News from the SharePoint Conference 2009 (part II)

I almost forgot - most exciting news is that November is public Beta time!

News from the SharePoint Conference 2009

Well, the show is on. The key note was done and I am sure a lot of people will start blogging like mad, so I will make an effort to contribute my thoughts. Unfortunately, this will be in more of a "thought of a day" (or "thought of a session") style - until I get time off my feet to write complete reviews of what I saw and what I think. But stay tuned as I do have a lot to say and tell you in the next few weeks, as I travel around the world to learn what is new in sharepoint
For now - some exciting tidbits:

  • SP2010 will support XHTML and WCAG standards
  • SP2010 will run on Vista and Windows7 for development!
  • SP2010 will have cross-farm content types for managing your taxonomy!
  • The replacement for BDC will finally allow you to do what you always wanted - show external databases as if they were sharepoint lists (including CRUD opperations)
  • When adding a web part to the page (page is in edit mode) you get a panel showing you the loading times for different lifecycle parts of the web part, the stack trace and the SQL commands sharepoint did for the web part, and how long each one took!
  • Web parts now have a visual editor in VS2010 - no more writing the UI in code
  • Client side model? I can't wait for that session to start...

Sunday, October 11, 2009

Selected pictures view does not work in Citrix

I wonder if anyone else can replicate this. My customer uses citrix to allow remote people to log in and use the intranet. When logged in, using IE8 through citrix, the "selected pictures" view in picture libraries doesnt work.
You go to a picture library, select a few pictures and then in the view selector you select the "selected pictures" view, and you get a view that shows you all the pictures, and does not show the checkboxes (some style issues there).
This is happening with a non-customized sharepoint site, and when you access the same list from a desktop on the network (so, not through citrix) there is no problem.
Anyone seen this? anyone solved this?

Wednesday, September 16, 2009

Retrieving the COM class factory for component with CLSID {3D42CCB1-4665-4620-92A3-478F47389230} failed

A code I was running against user profiles failed with the error: "Retrieving the COM class factory for component with CLSID {3D42CCB1-4665-4620-92A3-478F47389230} failed due to the following error: 80070422."
The reason was that the search service was disabled on the server, and since adding user profile properties that are indexed requires the search service, this error is understandable (although not very user friendly).
solution is obvious - start the search service.

Sunday, August 23, 2009

Tech Support Cheat Sheet

I actually did something similar when I was head of Microsoft Office Support in Israel in 2002 - regardless, if you are like me - the "computer expert" of the family, just email this to all your relatives and relax.

Tech Support Cheat Sheet

Wednesday, August 19, 2009

Web Parts – a developer and architect’s guide

Below are the slides from the presentation that I did in the SharePoint Saturday events in Sydney and Adelaide in the last two weeks. A lot of people asked me for it, but I am not sure how much help it can be to you if you haven't been there- since my presentations are more me talking and running demos, and less information from slides (I do love the sound of my own voice...).

If you still want to, here are the slides:

Oh - and credit to Fernando Felman for the wonderful list of links at the end. Here they are if you want to copy them:

Tuesday, August 18, 2009

Windows 2008 R2 goodness - adding sharepoint folders to a library

Just a heads up to what you can expect when you upgrade to Windows Server 2008 R2 (aside from all the technical things like virtualization improvements):

Win2008R2 is also known as “Windows 7 Server”, since the UI is windows 7 (unlike windows 2008 which was vista).

This means we can create “libraries” – which are virtual folders which replace the vista “search folder” with much more options.

An example is shown below – I created a virtual folder called “sharepoint files” and added the 12 hive and the office servers folders as well as the “logs” folder – and now I have an easy way to get to all three of them in windows explorer:
Bliss. Oh - can you see how I named my 2008 R2 machine?

Sunday, August 02, 2009

Creating Thesaurus files

I had a look at the excel file that Mauro Cardarelli wrote as a tool to generate thesaurus plans. While the tool is nice, I was dissapointed it did not include a facility to load an existing XML file and analyze it to see if it contains faults such as duplicates.

So what I did was write my own macro that loads a thesaurus file into Mauro's excel spreadsheet. The macro only loads expansions (as his spreadsheet does not deal with replacements) - but you can easily change it to load replacements if you want.

To use this macro, open Mauro's file, and open the visual basic window (alt-f11) and paste the procedure at the bottom of the "sheet1" module. To run it, either click the "run macro" button in excel, or from the VBA environment, hit F5 when the cursor is in the procedure. The macro will ask you for the path of the file, and will load it and populate the excel file.

Sub LoadThesaurusFile()
    Dim total As Integer
    total = 0
    Dim thesaurusFile As New DOMDocument
    Dim path As String
    path = InputBox("Path to the Thesaurus xml file", , ActiveWorkbook.path + "\thesaurus.xml")
    If (path = "") Then Exit Sub
    thesaurusFile.async = False
    thesaurusFile.validateOnParse = False
    'to avoid errors because of a thesaurus schema file, we will load the file as a text file, and then remove the schema reference
    Dim fs As TextStream
    Dim fso As New FileSystemObject
    Set fs = fso.OpenTextFile(path, ForReading, False, TristateUseDefault)
    s = fs.ReadAll
    s = Replace(s, "xmlns=""x-schema:tsSchema.xml""", "")

    Dim sht As Worksheet
    Set sht = ActiveSheet
    If (thesaurusFile.LoadXML(s)) Then
        Dim expansions As IXMLDOMNodeList
        Dim expansion As IXMLDOMNode
        Set expansions = thesaurusFile.FirstChild.SelectNodes("//expansion")
        'start from row 4
        Dim iCurrentRow As Integer
        iCurrentRow = 4
        'loop over the expansion tags, and populate the spreadsheet
        For i = 0 To expansions.Length - 1
            Dim iCurrentColumn As Integer
            Dim subs As IXMLDOMNodeList
            'load current exapnsion
            Set expansion = expansions.Item(i)
            'load the expansion subs
            Set subs = expansion.SelectNodes("sub")
            For iCurrentColumn = 0 To subs.Length - 1
                sht.Cells(iCurrentRow, iCurrentColumn + 1) = subs.Item(iCurrentColumn).Text
                total = total + 1
            Next iCurrentColumn
            iCurrentRow = iCurrentRow + 1
        Next i
        MsgBox ("Total entries: " & total)
    MsgBox ("Error loading the XML file: " + x.parseError.reason + vbCrLf + "Source:" + x.parseError.srcText + vbCrLf + "Link:" & x.parseError.Line)
   End If
   Set thesaurusFile = Nothing
End Sub

Sunday, July 19, 2009

In memory of a great sharepoint guy

Hi everyone.
If you followed this blog last year, you would have seen the blog post about Lee Marriage's death. Lee was a collegue who helped run the SharePoint user group in Sydney, and had a very useful sharepoint blog, and was a great guy all around.
Lee died last year in the Sydney "City to Surf" run from a heart attack. This year his friends are all going to do the run (or in some cases the walk) in his memory - while raising money for the Heart Research Institute.
If you can, please sponsor us on the everydayhero site: and donate a bit of money. I don't really care if you sponsor me specifically or any other member of the team.

Sunday, July 12, 2009

Setting the navigation options for a meeting workspace

This is just wierd. I had to change the navigation options for a meeting workspace using code on a MOSS farm. The meeting workspaces were all under a publishing site, with the publishing feature turned on, so the option to inherit the navigation from the parent site is available in the UI.
However, there is no option to set it in the API.
When dealing with publishing sites, you can easily set it by using the PublishingWeb object instead of the SPWeb object - but using PublishingWeb.IsPublishingWeb on the event workspace returns false.
So I had a look at the code that runs when you click OK on the navigation settings page - and guess what? Microsoft doesnt check if the site is a publishing web or not - they just assume it is, and set the properties! So I did the same, and the code runs great. It doesnt matter that it is not a publishing web.
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web); pubWeb.InheritGlobalNavigation = true;

Australian IT people - Want to learn about sharepoint?

SharePoint Saturday is coming to Sydney
This upcoming event (the 8th of August 2009 at the Microsoft Sydney Office) is going to be an awesome event with a lot of sessions - all about sharepoint. Think TechED - but only for SharePoint.

Join SharePoint architects, developers, and other professionals that work with Microsoft Office SharePoint Server 2007 for ‘SharePoint Saturday’, on Saturday, August 8th, 2009. SharePoint Saturday will be an educational, informative & lively day filled with sessions from respected SharePoint professionals & MVPs, covering a wide variety of SharePoint-orientated topics. SharePoint Saturday is FREE, open to the public and is your local chance to immerse yourself in SharePoint!
It is free, and there are many prizes (including my book), and if you come you can hear me talk about developing web parts - General Meeting: How to build real world web parts where I will demonstrate how to build a web part for SharePoint from scratch, and then will demonstrate some of the most elusive best practices that web part developers need to know.

Other sessions available are:
Building a Bulletproof SharePoint Farm; Disaster Recovery and High Availability for SharePoint
What SharePoint Administrators should know about SQL Server
Building Process Driven Applications leveraging SharePoint
ASP.Net and SharePoint
Content Deployment Bootcamp
Blooming SharePoint (SharePoint UI customizations)
Geographically Distributed Deployments for SharePoint
SharePoint as a platform for enterprise mash-ups
SharePoint Document imaging - The paper-laden office is here to stay
MOSS 2007 – Architecture best practices from the field
SharePoint Designer: Working with the DataView Web Part
Leveraging SharePoint Web Services

This whole event was organized by my friend Brian Farnhill - who has a great SharePoint developer blog that you should check out if you didn't already, and by fellow MVP Ben Walters - also a great guy all around.

Wednesday, June 24, 2009

Error message when checking in a document from office 2003

In a custom solution I recently worked on we were receiving an error from office applications when we tried to check in documents from within office 2003 applications like word or excel. The error was: "Cannont perform this operation. The file is no longer checked out or has been deleted" After a lot of digging, I found that the fault was in the custom content types that we deployed as features. The problem was that the person who wrote the CAML for the content types that inherit from the "Document" content type thought (understandably so) that it is enough to specify only the fields that the custom content type adds on top of the built in column. This meant that the content type did not have the right columns for file name for example. This was ok in the web UI or in office 2007 - but office 2003 must have some hard coded references that it missed, and it kept throwing errors. The solution was simple - add a reference to the built-in columns in each content type - even if it does inherit from the document content type. The following are the columns I had to add to solve the issue:

<!-- out of the box document columns--> <fieldref id="{5f47e085-2150-41dc-b661-442f3027f552}" name="SelectFilename"> <fieldref id="{8553196d-ec8d-4564-9861-3dbe931050c8}" name="FileLeafRef" required="TRUE"> <fieldref id="{8c06beca-0777-48f7-91c7-6da68bc07b69}" name="Created" hidden="TRUE"> <fieldref id="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" name="Title" required="FALSE" showinnewform="FALSE" showineditform="TRUE"> <fieldref id="{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}" name="Modified" hidden="TRUE"> <fieldref id="{822c78e3-1ea9-4943-b449-57863ad33ca9}" name="Modified_x0020_By" hidden="FALSE"> <fieldref id="{4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb}" name="Created_x0020_By" hidden="FALSE">

So that solved it for the content types - if I added those content types to document libraries, there was no more issue of checking documents from office 2003. However, if you are adding the content types to the document library using either a feature (elements file with ContentTypeBinding) or using schema.xml, an incorrect character or binding in the xml files may also trigger the same issue. so beware!

Using the Today token in a CAML query

I just noticed today that the CAML creator application that I am using (by U2U) does not handle the today token properly (at least the version I have).
The Today token is used in views, when you want to filter on a date based on the current date. For example, if you want to set up a view that shows future events you set the filter on start date > "[Today]".

However, in CAML, you cannot use "[Today]" - the square brackets cause the query to break. Instead, you use "<Today />".
For example:
<Where><Geq><FieldRef Name='EventDate' /><Value Type='DateTime'><Today /></Value></Geq></Where>

Tuesday, June 02, 2009

Read bits of my book in google

I just discovered that Google has bits of my sharepoint book that you can see for free- including the section on keyboard shortcuts (which I think is useful to print and put on the wall). Take a look (and feel free to write a review either there in google or here in the comments). The link is

Sunday, May 31, 2009

Easy links to remember for asking sharepoint questions

I hope this will be useful for someone - I made two tinyurls to help me (and others) remember the links to the sharepoint discussion forums in msdn. this way, all you have to remember is and the text that I added:

SharePoint Products and Technologies Forums home page:

SharePoint general questions forum:

SharePoint development forum:

SharePoint How To Book is published and in print

Hi everyone. This is to let you know that my book - SharePoint 2007 How-To is now available for purchase as either paperback or pdf or for kindle or sony reader or whatever format you want.

This book is probably not for the regular reader of my blog, since this blog deals with development issues, and the book is targeting end users - so if you are a developer or a sharepoint administrator, you may want to consider this book as the end user training tool for your users. Teach them how to use sharepoint.

When writing the book I had a target in mind - I did not set out to write the difinitive sharepoint guide. The book does not have everything about sharepoint. Instead, it helps the user with the most common tasks that an end user just has to know to be able to use a sharepoint site. So, while there is much more to learn beyond the book, I feel the book gives the reader a good basis to start the learning - without being a heavy, forbidding book that is hard to read (or indeed lift).
I am very interested if anyone who read the book can let me know if they think I achieved that goal. Please, if you have read it - can you leave constructive feedback either here (comment on this post) or in the book's page in Amazon (under "Customer Reviews").

Just so you get a feel what is in the book before you consider buying it (Amazon will let you read parts of it if you want), here is the table of contents:
Part I, "Solutions for Readers", has the most common and basic tasks that do not involve changing anything in SharePoint, but just viewing, browsing, and finding information. This part includes:
Chapter 1, “About Microsoft SharePoint 2007”
Chapter 2, “Finding Your Way Around a SharePoint Site”
Chapter 3, “Solutions Regarding Files, Documents, List Items, and Forms”
Chapter 4, “Searching in SharePoint”
Chapter 5, “Personal Sites and Personal Details (Available Only in MOSS)”

Part II, “Solutions for Authors and Content Managers”, teaches you how to perform tasks that involve adding content to SharePoint or changing the way it looks. This part includes:
Chapter 6, “Creating and Managing Files, List Items, and Forms in SharePoint”
Chapter 7, “Creating Lists and Document Libraries”
Chapter 8, “Creating List Views”
Chapter 9, “Authoring Pages”
Chapter 10, “Managing Security”
Chapter 11, “Workflows”

Part III, “Solutions for Site Managers,” has advanced tasks involved in creating andcustomizing SharePoint sites. This part includes:
Chapter 12, “Creating Subsites”
Chapter 13, “Customizing a SharePoint Site”
Chapter 14, “Managing Site Security”

Finally, I list Common Keyboard Shortcuts for sharepoint (which may surprise you) and useful links to pages that every sharepoint site has (for example- how to get to the "Site content and structure" page or to the page that shows the list of last content you edited... again - this may surprise even the expirienced user.

So what do you think? useful? useless? are you going to buy this? do you need this for end user training? Should I change anything if I write another book for the next version of sharepoint? I'd love to hear what you have to say...

Monday, April 20, 2009

Access denied in win2008 with a custom host header

As usual - I failed to write this down when it happened before, and every time I encounter this issue I fail to remember how to solve it.
The issue - you install a new sharepoint machine and create a web application with a custom host header and then try to browse to it from the server itself using the host header (which is correctly configured in the DNS and host files and all) and you get prompted for a username\password three times and then get thrown out.
This happened with sharepoint 2003 as well, and with windows 2003 server and has the same reason behind it - a loopback check on the server. In 2008 however it threw me several times when I created a web application, and browsed to it and it worked and then I had to recreate it and it suddenly stopped working from the server, while other machines could browse to it with no issues. arrrggghhh!

So, if you have a web application with a custom host header, and if you browse to it from a client machine you can view the sites, but from the server you get prompted for password and nothing you enter works...try the solutions described in this KB article (KB896861). I know the title refers only to IIS 6, and I know the article mentions windows XP and windows 2003 - trust me, it solves this issue for windows 2008 just as well.

Tuesday, March 10, 2009

Fix for the infrastructure update picture library bug

If like me you find the infrastructure update ruined your picture library views, check out this hot fix that microsoft released

Wednesday, February 25, 2009

Finally - a solution to having bluetooth in windows 2008

As you know, I run windows 2008 on my laptop - to take advantage of hyper-v, and to be able to develop and demo sharepoint FAST.
The only problem I had so far was the bluetooth - which I solved in past installations, and then something broke and I couldnt get it to work again. Well - if you have the same problem as me, here is the solution that solved my issues:

Monday, February 09, 2009

Preventing IIS from logging activity on a specific sharepoint site

A friend at "Kraft Foods" sent me the following tip to share with you. I must say that I didn't try it myself - so use at your own risk.

The problem
IIS logs activity for a sharepoint web application, for all sites. If you have a web application with a lot of sites, and a lot of activity, the IIS logs may grow out of proportion and make analysis of the logs harder and harder. What if you don't want it to audit all sites, but just some of them? what if we want to exclude a certain site that is hit often, and we don't care if it is audited by IIS?

Well, if our site was a regular .net site, we would have the folders of that site (the virtual directories) shown and we could mark places in the hierarchy that we do not want to audit. But SharePoint does not create virtual folders in IIS, instead IIS has only one folder for all site collections in the web application.

The solution
According to my friend, the solution is to manually create folders under the IIS physical folder by the url names of the sites that you want to exclude. For example, if you have a site called "News" that you want to exclude from the logs, go to "C:\inetpub\wwwroot\wss\VirtualDirectories\{your web application}" and create a folder "News". Then, in IIS right click the folder, and configure it to be excluded from the logs.

More Info
I couldnt find how to exclude the folder in windows 2008 - but in IIS6 you can do that under "Directories" tab, by setting "Log Visits" = unchecked.

Sunday, February 08, 2009

New MOSS internet site launched - good case study

One of the three Israeli mobile communication companies has released a new web site – using MOSS. From my initial review, it is one of the best implementations I have seen so far in that it:

  1. Works (I couldn’t find a page with errors or place holder text which is usual in new sites)
  2. works reasonably fast
  3. usable – nice big global navigation, in sub sites there is a nice distinct secondary navigation
  4. different sections have different backgrounds – so the shop pages look different from the customer relations pages
  5. makes use of personalisation – users can log on, see their account and special offers
  6. even search looks good and is optimised with keywords and best bets – although they could have used a different font for the description to make it different from the link)
  7. system pages are properly disabled – showing a user friendly error message
  8. same for page not found error
The site (which is in Hebrew) can be found under

Does anyone know who built the site for them? kudos!

Sunday, February 01, 2009

Dispose check tool - to check your best practices

Paul Andrew from Microsoft has just announced that the SPDisposeCheck tool was released to the public. I have tested this tool in Alpha and Beta, and provided Microsoft with feedback -and now the completed tool is ready for you to download. A must for every sharepoint developer! See Paul's blog post or go to the MSDN download page

Monday, January 26, 2009


I was puzzled why on my development server the memberships web parts never showed the sites that my test users were members of. After much searching and tinkering I found that I needed to run a full profile import and a full search crawl. It could be that only one was required - but I cannot verify it. The profile import does say that it updates memberships, but even after that it didnt add the memberships - only after I performed a full search crawl that it started working.

Tuesday, January 06, 2009

Discounted Microsoft Certification code

Want to do a Microsoft certification exam? is it a Microsoft Certified Technology Specialist (MCTS), Microsoft Certified IT Professional (MCITP) and Microsoft Certified Professional Developer (MCPD) exam?

Here is how you can get 10% off the price, and get a free retake if you fail the first try. Simply go to and click on "Get my exam offer voucher" and when it asks you for the MVP promotion code, enter AUD2D426 and you will be sent a voucher to use in a Prometric exam centre of your choice.
This offer is valid until March 2009 - so go on, get the vouchers and start taking exams!
Have fun!