Wednesday, October 27, 2010

SharePoint 2010 Replaceable Parameters

Replaceable parameters is one of the nicest new features implemented for Visual Studio 2010 Tools for SharePoint 2010. I won't go into elaborate detail because this feature is well documented here, here, here and here, just to name a few places. What I do want to do is point out a few things that may help you avoid frustrations.

1. In a standard SharePoint 2010 pr
oject, ASMX files do not get parsed. What this means is that you would have to hardcode your assembly information in these files. But, as MSDN has pointed out here you can edit your csproj to include new file extensions.

GREAT! Now we can have files other than ASPX, XML etc. Our ASMX files, amongst others, are now parsed and the tokens are replaced.

2. When using the following parameters:

  • $SharePoint.Type.<guid>.AssemblyQualifiedName$

  • $SharePoint.Type.<guid>.FullName$

always ensure that the GUID is lower case. I spent hours trying to figure out why this parameter wasn't being replaced. This problem came about because most people, including myself, just used the GUID Generator. The GUID Generator returns uppercase GUIDS. Here is something that will save you time. In Visual Studio you can select the inserted GUID, hit CTRL + U and voila, you now have a lower case GUID. For example




3. SNIPPETS are an amazing feature when used in conjunction with the replaceable parameters. If you go here, download and install the snippets package, you can now right click and insert any of the replaceable parameters directly into your files. No need to look up or remember any of them! SWEET!

I'm not saying anything I've said here is ground breaking, but I'm just trying to save you some time. For me, being able to insert a GUID, make it lower case and then use a snippet to insert the token into my file makes my SharePoint development easier.

Tuesday, October 26, 2010

Site Navigation Tree Web Part goes on codeplex

Finally got the time to put this nice free webpart on codeplex.

We had it on our site as a free download, but now you can get the source code as well!

It also features a very cool, fast and simple tree controls - one of the first tree controls I ever written that use pure ASP.NET - no AJAX or any other framework needed!

Let me know if you like it,
Next - I have to release our "feature visibility" feature (dumb name :) ) - which is a farm feature that allows you to show/hide certain features on specific web applications, site collection or sites.

Again - this one is shipped free with our wiki plus solution and it is about time it will go on codeplex!

Friday, October 1, 2010

Most annoying error message in SharePoint development

How much do you hate this error message: "One of the properties of the Web Part has an incorrect format. Microsoft SharePoint Foundation cannot deserialize the Web Part. Check the format of the properties and try again."?

If you are like me, creating lots of SharePoint web parts - you must have seen this hundreds of times.

See my old post on this issue: unable to add selected web part(s)

It does not give you any useful information as to what went wrong, you cannot debug it and basically you were blind folded to resolve this issue on your own.

What if I tell you, that there is a way to get the internal error message that will let you know exactly what you did wrong in code, DWP, or anywhere else?

Well, as I have learned today - there is such a way, and it is rather simple.

First, you have to make sure your server shows complete error messages and not these nice custom error page. Simply edit your web.config (back it up first!) and change CallStack="false" to CallStack="true", and also change the to

Now, you install your web part, try to add it to a web part page and boom – this happens…
The trick is, to go to site collection settings -> Galleries -> Web parts and find your web part definition there.

Once found – click on the file name link to get a detailed error page with stack trace and everything!

Note, that you will get a complete error message the first time:

And the same limited information all other times:

So be sure to keep the error page open first time until you got all the info you need!

Strange, but at least we got something!