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...

W3SVC Deadlock Detected by Debug.Assert in ASP.NET 2.0

by on Nov.25, 2010, under ASP.NET 2.0, iis, Programming, W3SVC

After a hard day with some errors failing a production server at a customer I had to find out what caused all these troubles… Well I had alot of messages in the Application Log with the messages ViewState verification failed… what’s causing all these messages? Well I had to find it out… So after some research it could be alot of things that causing these messages, but I couldn’t find out which one it was…

Till I found another error message in the System Log… these messages caused a Deadlock on the Thread, and if this happens IIS will create a new Thread that will continue, but after 20 deadlocks IIS went down… hmm odd, so I found out that this came from the application. And it came from the System.Diagnostics.Debug.Assert, but huh, I thought that I had delivered a Release version. Well maybe, maybe not. So I knew for some reason this was causing all these messages.

Well I thought that I could kill these messages by setting debug=”false”, well I can assure you, that won’t work. I had that figured out the next day, when the Administrator called me that the production server went down every 5 to 10 minutes… hmm so I called Edward Bakker, and asked him if he had a solution. After some talking with each other and Internet by hand I searched and came out by the blog of Scott Hanselman. And he had the solution for my problem.

This problem can cause severe damage and it seems to be a bug in ASP.NET 2.0… Thanks to Scott and Edward I managed to figure it out.

Link to blogpost by Scott Hanselman:

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...

The mess of upgrading Solutions to SharePoint 2010

by on Oct.03, 2010, under Programming, SharePoint 2010, Software, Visual Studio 2010

The first of all is, when you go to a customer for a simple upgrade to SharePoint 2010 isn’t going to be easy. Why, well Rick Taylor is one of the masters of upgrading to SharePoint 2010, and now I know why he is preaching about all the mess you going to have with upgrading to SharePoint 2010.

A simple thought about upgrading isn’t going to be, why? Every customer has custom solutions, changed css’s or anything of that stuff, but it’s going to be worse. When you have Site Definitions, what is not the best practice of course it is going to be alot worse. All kinds of developers are writing and developing nice Site Definitions but when you are at the stage you want to upgrade these developers kan start all over again. Yes, because they put everything in a solution. Every complete customized lists, document libraries and blogs.

Wow, well if you are an architect or a business manager and you hear about Site Definitions and you’re upgrading to SharePoint 2010. You can think twice, and even need to save some money to hire a developer that can write all the site definitions again which are not best practice off course. Yes, why I am writing this blog, because I just started to upgrade some solution that is written if all the above mess. Customized blog pages, document libraries, lists, etc. Yes we make features and we make site definitions and we put them all in one bucket called a WSP and hopefully it will work under SharePoint 2010, because you’ll never know.

Leave a Comment :, , , , , , , , , , more...

Timestamp and validation

by on Jul.13, 2009, under Programming, sql server, SSIS

Timestamp in SQL Server:

1) The SQL Server timestamp data type has nothing to do with times or dates. SQL Server timestamps are binary numbers that indicate the relative sequence in which data modifications took place in a database. The timestamp data type was originally implemented to support the SQL Server recovery algorithms.

2) It further states Never use timestamp columns in keys, especially primary keys, because the timestamp value changes every time the row is modified.

For a customer we made some changes. And the situation is as follows. We exported the data to excel. Multiple tabels are exported. We changed the data in the excel file and the customer validated the data. We also did export the timetamp with the data. Why? Because we had to import it again to the database. If a Timestamp changed, we should not update the data from the excel file. That’s why.

Problem situation:

Because a timestamp isn’t a varchar, or numeric value, but a binary(8) value we had to convert it. Because we import the data by SSIS back into the database. But the data we imported is from a flat text file. So every column was read as a DT_STR by SSIS, and timestamp in the stored procedure was a datatype of Timestamp. So we did a comparison of a varchar against a timestamp. Well that situation didn’t work out that well.

So what we did was to change the parameter of the stored procedure to varchar. Well SQL Server can’t handle a comparison of varchar against timestamp inside the stored procedure. Of course, so we did try it to convert it to a varbinary(8) or binary(8) and then validate it against the timestamp. Well that didn’t work out that well.

declare @timestamp varbinary(8)
set @timestamp = CONVERT(varbinary(8), '0x0000000001F4AD88')
print @timestamp

returned: 0x3078303030303030

declare @timestamp varbinary(8)
set @timestamp = CONVERT(varbinary(8), 0x0000000001F4AD88)

print @timestamp

returned: 0x0000000001F4AD88

That comparison didn’t work well. So I had to figure an other way to validate on timestamp. When I almost lost my hope I wrote a function in SQL Server.

create function [dbo].[sp_hexadecimal] ( @var varbinary(255) )
returns varchar(255)

      declare @charval varchar(255)
      declare @i int
      declare @length int
      declare @hex char(16)

      select @charval = '0x'
      select @i = 1
      select @length = datalength(@var)
      select @hex = '0123456789abcdef'

      while (@i <= @length)
            declare @tempint int
            declare @firstint int
            declare @secondint int

            select @tempint = convert(int, substring(@var,@i,1))
            select @firstint = floor(@tempint/16)
            select @secondint = @tempint - (@firstint*16)
            select @charval = @charval +
            substring(@hex, @firstint+1, 1) +
            substring(@hex, @secondint+1, 1)

            select @i = @i + 1

return ( @charval )

So what I did was the other. I managed to validate the data on the other way.

it did the trick...

Leave a Comment :, , , , , , , , , more...

DataFlow in SSIS and OLE DB Command

by on Jul.11, 2009, under Programming, sql server, SSIS

I’ve been working for the first time with a DataFlow of updating data in a SQL Database with SSIS. The only problem is that a colleaque did made it, but he forget something with it. After reading some documentation about the DataFlow in SSIS and the using of a OLE DB command to execute a Stored Procedure I came to a certain problem.

The problem is that a OLE DB Command can execute a Stored Procedure, but the error handling is really a issue. Why, you can give a output parameter with it, but for some reason it doesn’t work well. The question is why they didn’t use a SQL Task to execute a Stored Procedure. Now I’m searching why my stored procedure isn’t fired well.

Well the problem is that the stored procedure contains a error handling not supported by the OLE DB Command. And when you have error handling handled by you SSIS you get a Error Number 0 returned. So your searching for a problem with Error number 0? That’s really crap. So I get rid of the Error handling in the stored procedure, and well the funny thing is that the stored procedure really is fired well and with filled parameters. But another problem is now that there are not enough parameters filled to execute the Stored Procedure properly.

So I have to search for that issue to solve the problem….

Leave a Comment :, , , , , , , more...

How to overcome performance issues with Javascript in IE for ASP.NET controls

by on May.11, 2009, under Programming

Well if you use third party web controls like Telerik or Infragistics you can have performance issues. It’s running like an old crappy site.

To overcome this and you use Javascript or it will be rendered by Javascript you can enhance it by writing your Javascript in one single line.

Check this site for Bookmarklets

Leave a Comment more...

Stored procedure for Reindexing and Update Stats

by on May.09, 2009, under Programming, sql server

Well I was searching for a Stored Procedure that you can use for reindexing and updating stats, etc.

I didn’t find any nice procedures that gave me the solution I needed, so I’ve read some posts by google, and made the following procedure 🙂

This procedure will loop through all the tables and all indexes and shall Reindex them. When every index on every table is reindexed it will update all the stats on the database.

Of course you can choose to change the fill index from 80 to any other valid percentage.

  2. CREATE PROCEDURE spUtil_ReIndexDatabase_UpdateStats
  3. AS
  4. BEGIN
  5. — SET NOCOUNT ON added to prevent extra result sets from
  6. — interfering with SELECT statements.
  8. DECLARE @MyTable VARCHAR(255)
  9. DECLARE myCursor
  11. SELECT table_name
  12. FROM information_schema.tables
  13. WHERE table_type = 'base table'
  14. OPEN myCursor
  16. FROM myCursor INTO @MyTable
  18. BEGIN
  19. PRINT 'Reindexing Table:  ' + @MyTable
  20. DBCC DBREINDEX(@MyTable, '', 80)
  22. FROM myCursor INTO @MyTable
  23. END
  24. CLOSE myCursor
  25. DEALLOCATE myCursor
  27. GO
  28. END
Leave a Comment :, , , , , , , , more...


by on Apr.02, 2008, under Programming

Well I know that for VS 2005 or VS 2008 can maintain your web or app configuration file with alot of easy. Well adding shouldn’t be a harsh, but updating still is a somekind of problem. Allright, normally you have a static connectionstring for your (web)application. Well the company that I work for has an application that isn’t static at all.

Everything is dynamic, even the connectionstring. You know why? Well the application that someone made was used for multiple databases. And it is used for importing data. You can change the connectionstring by editing the web or app config. But that wasn’t an option. The people that use this application should change the connectionstring by the application itself.

Allright, the fellow that created this nice application wasn’t aware of the connectionstring configsection. So he didn’t used that part, but I said, well if you change a connectionstring, you can maintain it by ease with code. So I had to write two simple functions. Adding and updating of connectionstrings.

The first part of the code is adding the connectionstring. Well I used this code the Windows Application so I didn’t include any for web applications.

Well opening of the configuration file is used by the configurationmanager. The ConfigurationManager.OpenExeConfiguration is used for opening the app.config, with ConfigurationUserLevel none. So no user level is needed.

Then you take out the ConnectionString section.

/// <summary>
  1.         /// Add a connection string to the connection
  2.         /// strings section and store it in the
  3.         /// configuration file.
  4.         /// &lt;/summary&gt;
  5.         /// &lt;param name="csName"&gt;The name of the property.&lt;/param&gt;
  6.         /// &lt;param name="connectionString"&gt;The connectionstring as specified.&lt;/param&gt;
  7.         public static void AddConnectionStrings(string csName, string connectionString)
  8.         {
  10.             // Get the configuration file.
  11.             System.Configuration.Configuration config =
  12.                 ConfigurationManager.OpenExeConfiguration(
  13.                 ConfigurationUserLevel.None);
  15.             // Add the connection string.
  16.             ConnectionStringsSection csSection = config.ConnectionStrings;
  17.             csSection.ConnectionStrings.Add(
  18.                 new ConnectionStringSettings(csName,
  19.                     connectionString, "System.Data.SqlClient"));
  21.             // Save the configuration file.
  22.             config.Save(ConfigurationSaveMode.Full);
  23.         }

Well for updating it was hard to find any usefull code to update a connectionstring. It wasn’t possible to update a connectionstring, so I had the remove the connectionstring, and add a new one. Well isn’t that odd?? Microsoft left something undone… Well maybe it isn’t usefull to change your app.config, but well, I had to make it anyhow. So dynamic app.config or web.config files is little bit strange, because you can’t dynamically update it. No you have to remove it first by the configurationmanager.

<pre lang=”csharp”>

/// <summary>
  1.         /// First remove the old connectionstring and after that
  2.         /// add a connection string to the connectionstrings
  3.         /// section and store it in the configuration file.
  4.         /// &lt;/summary&gt;
  5.         /// &lt;param name="csName"&gt;The name of the property.&lt;/param&gt;
  6.         /// &lt;param name="connectionString"&gt;The connectionstring as specified.&lt;/param&gt;
  7.         public static void UpdateConnectionStrings(string csName, string connectionString)
  8.         {
  9.             // Get the configuration file
  10.             System.Configuration.Configuration config =
  11.                 ConfigurationManager.OpenExeConfiguration(
  12.                 ConfigurationUserLevel.None);
  14.             // Remove the existing connectionstring.
  15.             config.ConnectionStrings.ConnectionStrings.Remove(csName);
  16.             // Add the connectionstring
  17.             ConnectionStringsSection csSection = config.ConnectionStrings;
  18.             csSection.ConnectionStrings.Add(
  19.                 new ConnectionStringSettings(csName,
  20.                 connectionString, "System.Data.SqlClient"));
  22.             // Save the configuration file
  23.             config.Save(ConfigurationSaveMode.Full);
  24.         }
  25. &lt;/pre&gt;
Leave a Comment :, , , , , , , , 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...