Error: “SharePoint Foundation cannot deserialize the Web Part”

Here’s another one of those “Why didn’t I ever figure this out before?” things. Many times when I’m editing pages in SharePoint Designer and everything is going along swimmingly, suddenly I hear the Jaws theme and I get an error like this:


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.

Of course, the error message is as clear as mud. What happens is that SharePoint Designer messes with the properties of a Web Part, making them unintelligible to SharePoint on the server.

Here’s what I mean. If you look at the code below, you’ll see that the values for the properties are not on the same line as the tags which enclose them.


In this closer view, I’ve added arrows pointing to two instances of the issue, though every line from 133-141 demonstrates the problem.


The fix is amazingly simple, but a little tedious. All you need to do is fix the code so that the tags enclose the values again, and you’re good to go.


I haven’t figured out a pattern where SharePoint Designer decides to go all flaky on me like this other than “it does it sometimes”. It’s yet another reason to commit to keeping your code nice and clean and well-formatted so that you can spot issues like this easily.

Enhanced by Zemanta