André Krijnen


Use Content by Query Web Part on a Fixed List created dynamic in an onet.xml

by on Nov.07, 2011, under features, Programming, SharePoint 2010

There is nothing as worse as a Content By Query Web Part that you can’t use when you want to fix it against a List which will be made automatically for example.

I would like to create a Team Site based on a Custom Web template with an extra sub-site with blogging functionality. This blogging functionality is used for exposing news of the Team or Department.

But when using the functionality like

<Property name=”WebUrl” type=”string”>~site/News</Property>

and using the property

<Property name=”ListName” type=”string”>Posts</Property>

and you removed the value of the property

<Property name=”ListGuid” type=”string”></Property>

it won’t render the CQWP web part by default. The reason is that the ListGuid is needed to render the Web Part.

But also an issue is that, when your list is created it has a changed ListGuid. The ListGuid is never the same when you create a new List.

So basically I created the follow code which will fix that issue.

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.Publishing.WebControls;

namespace AK.Custom.CQWP 
    public class AKCQWP : ContentByQueryWebPart

        protected override void  OnLoad(EventArgs e)
 	        if(!string.IsNullOrEmpty(this.WebUrl) && 
                !string.IsNullOrEmpty(this.ListName) && 
                SPWeb webRoot = SPContext.Current.Site.OpenWeb();
                if (this.WebUrl.StartsWith("~site"))
                    this.WebUrl = this.WebUrl.Replace("~site", "");
                    using(SPWeb web = SPContext.Current.Site.OpenWeb(webRoot.ServerRelativeUrl 
+ this.WebUrl, true))
                        SPList list = web.Lists[this.ListName];
                        this.ListGuid = list.ID.ToString();
                        //this.ListUrl = webRoot.ServerRelativeUrl + this.WebUrl;
                        this.WebUrl = webRoot.ServerRelativeUrl + this.WebUrl;
                else if(this.WebUrl.StartsWith("/News"))
                    using(SPWeb web = SPContext.Current.Site.OpenWeb(this.WebUrl, true))
                        SPList list = web.Lists[this.ListName];
                        this.ListGuid = list.ID.ToString();
                        this.WebUrl = this.WebUrl;


        protected override void OnInit(EventArgs e)

        protected override void CreateChildControls()

When you have created this part of your solution ensure that you Export the standard CQWP and edit it like you want to. First of all, what you need is to ensure that it takes your assembly instead of the default CQWP assembly.

      <type name="AK.Custom.CQWP.AKCQWP, $SharePoint.Project.AssemblyFullName$" />

Change the properties as following:

<Property name=”WebUrl” type=”string”>~site/News</Property>
<Property name=”ListName” type=”string”>Posts</Property>
<Property name=”ListGuid” type=”string”></Property>
Leave a Comment :, , , , , , more...

sharepoint 2010: localized resource for token ‘direction’ could not be found for file with path

by on Nov.07, 2011, under features, Programming, SharePoint 2010, SharePoint Foundation

A quick blog about the ‘Localized resource for token ‘direction’ could not be found with path ‘feature path’ is an issue when you have generated a List Definition. When you deploy a list definition in a feature without a Default Core Resource file you will run against this message. It seems to be introduced by the 2010 December update, and it also seems to be solved by the SP1 of 2011 June Refresh update, but I can’t say for sure.

I have installed some language packs on my dev machine, and it does work without any problems, but the environment I want to deploy to seems to have this issue for one reason or another.

Leave a Comment more...

Feature Deployment SharePoint 2010 (List Instance and List Definition)

by on Nov.07, 2011, under features, General, maintenance, Powershell, SharePoint 2010, SharePoint Foundation

So I started out today debugging some weird issues regarding feature deployment. And well sometimes I don’t know why I get errors, but what’s new. So first of all, let’s start where to start.

cannot complete this action.please try again

Starting point:

A colleague of mine had written a feature for a customer of us, which worked perfectly. The customer had never issues like it should. After almost a year we (me, and the customer) decided to change the full Site Templates. Like a developer should do is making and changing the solution work. Well then comes the burden. After days of work, testing everything out the solution worked by me. (Owwh yeah, the known starting point: well on my computer it works).

So after deployment at the production server it didn’t work. I didn’t knew why, because everything should work like my notebook. The reason is simple, I had the same configuration, databases, etc. Well that didn’t work that out to.

So I thought well, let’s start fresh with new content databases from production. Ahh yes, there we go. Well, at my notebook it didn’t work either. Whoehoe, nice, we’ve got a good starting point for debugging.

Visual Studio 2010:

So I worked with Visual Studio 2010 and the deployed the feature again to debug. Well. Strangely, the solution worked after that. So Microsoft did some tricks while deploying. So I searched and called some people, yes on sunday. And telling me that Visual Studio 2010 is deploying asychronously. Yeah I knew that, but after a minute and some conversation telling that Powershell is deploying synchronously. Well that the trick I thought. So I decided to help my self out with some times, running the admin jobs, etc.

Even that didn’t worked out.

Go debugging old fashioned style: disabling Web and Site scoped features in the onet.xml.

After the first Web Feature (Deploying some List Instances and List Definitions) disabled the solution worked by powershell. I didn’t have a clue, but ohh well, I decided to change the ordering of the feature. Instead of List Definitions first, I decided to set the List Instances first. And you know what, It worked.

After enabling the Web Feature again, I could run the New Site creation perfectly.

Leave a Comment more...

Invalid features SharePoint 2010: Features due to a Failed, Missing, or Unsuccessful Activation SharePoint WSP

by on Oct.04, 2010, under features, Powershell, Programming, SharePoint 2010, SharePoint Foundation, Visual Studio 2010

Every developer has one of those days that everything goes wrong. You developed some feature, and you decided to change the namespace of the feature. For some reason or another SharePoint 2010 doesn’t handle this well, and even Visual Studio 2010 doesn’t know how to handle it. So you received a message that you allready activated a feature with the same Id you want to deploy? And you can’t revert it in someway?

Well I thought to use PowerShell to uninstall these spfeatures which I tried, but the message was cloud and clear, can’t uninstall feature, because feature isn’t found? Huh?? Why is that? Well I tried Get-SPFeature to retreive all the features I installed, and what did I see? My features standing in that list, so I tried to remove it by Id, and what happend? Can’t find feature by Id? Crap you would say? Well I used the WssAnalyzerTool from and managed to get all the failing features.

Then I tried to run the WssRemoveFeaturesTool from the same site, but what did you say? Even that tool couldn’t find that feature… Imagine that… So the last resort: yes the plain old fashioned stsadm. Did that work well, yes!! It worked more then you could think off.

stsadm -o disablefeature -Id -force ==> Operation completed successfully
stsadm -o Uninstallfeature -id -force ==> Operation completed successfully

So you think you can do everything with powershell, well sometimes you can, sometimes you can’t.

2 Comments more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!


A few highly recommended websites...