Decoding SharePoint error messages

I had just activated a new feature on a WSS 3.0 site, and attempted to add one of its Web Parts to a page, when up came a helpful error message:

“The Web Part you attempted to add no longer exists in the Closed Web Parts Gallery.  Refresh your browser to update the Web Part Page and the Gallery.”

But the problem is that I attempted to add an Ajax web part to a page without first installing ASP.NET Ajax.  Daniel Larson said it best: “This is the WORST error handling ever.” This error message offers almost no help.  Daniel Larson’s blog post on the other hand, was a big help (many thanks)!

 

image

 

This brings to mind another infamous SharePoint error message that appears after modifying any aspect of a “ghosted” page with SharePoint Designer, which moves the page to an “unghosted” state (i.e., the page is moved from disk into the content database) and causes the page to be executed in Safe Mode.  If any inline scripts are in the page, you might see this friendly reminder:

“An error occurred during the processing of /SomeDir/SomePage.aspx. Code blocks are not allowed in this file.”

This message makes sense after you’ve seen it a few times, but isn’t very helpful if you’re new to WSS, and making even a trivial change breaks your page.  Modifying web.config to always allow server scripts to run is a quick and dirty fix for this one:

<PageParserPath VirtualPath=”/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />

But a better (more secure) approach would be to create a custom server-side control, and explicitly register it as safe in web.config :

<SafeControl Assembly=”MyApp, …” Namespace=”MyApp.Controls” TypeName=”*” AllowRemoteDesigner=”True” />

I suspect Microsoft is letting developers write their own error messages, which might explain why they read like code.  As long as people keep blogging their solutions though, I’m happy.

Leave a Reply