Tuesday, June 24, 2008

Unable to add selected web part(s).

You know this error?

You just developed a new web part, all excited and ready to test it and wham!

Unable to add selected web part(s).
[Web Part Title]: One of the properties of the Web Part has an incorrect format. Windows SharePoint Services cannot deserialize the Web Part. Check the format of the properties and try again.

Well, this keeps happening to me (not the first time, and definitly not the last) so I thought I'd share one of the reasons for this message to appear.

This meesage can apear in various situations - so feel free to comment with your own "check list" for this error.

Reason 1:
Check your class definitions. In most cases - if you forget to mark it as "public class" you will get this error.

Reason 2:
Check your properties definitions. Could it be that custom logic in get/set throws and exception?

Reason 3:
Check your DWP/Webpart file. It may point to a property that does not exist (removed / spelling mistake), or the assembly is not registered correctly. Best way to troubleshoot this is: Go to your site collection settings, to web parts gallery, click "new" and add your web part to the gallery. Try the new DWP/Webpart file created - does it work?

Reason 4:
For Bin installations - make sure your DLL is in the bin folder of the current web application. Make sure it is registered as safe control in the web.config with no spelling mistakes.

Reason 5:
For GAC installations - make sure your DLL is in the GAC, if you changed it recently try an IISRESET. Also - Make sure it is registered as safe control in the web.config for each web application with no spelling mistaked.

Ok, this is what I can come up with now... Share your experience, this error can get pretty annoying!

Hope I helped save lifes on this (or at least, made the world a better place with less developers screaming in the middle of the night).

Brought to you as a public service by Shai, KWizCom :)

8 comments:

MOSSDeveloper said...

Thanks for sharing I am struggling with thsi issue right now will let you know when its over

Anonymous said...

Thanks for the post.
Joydeep B

RoyJoyson said...

Thanks buddy. cant we have int as property types 4 tool part?. I got the same error and went off after replacing int with string

amit said...

Hi I have done everything as you have said, it not giving any error but it is also not showing in webpart gallery..
please help meeeeee

Shai Petel said...

Hi Amit,

if you need help you can email me to shai at kwizcom.com

thanks,

bparrish said...

I found an issue that I cannot tell you exactly how the problem arises, but the fix was that I forgot to change the web.config file in some areas as the manual stated. I did change the trust level to "Full" instead of "WSS-Minimal" and changed Session configurations within the file as well.

Shai Petel said...

Changing trust level of web.config to Full is not the best solution, as many IT departments will not allow that.

If this solved your issue, it means your DLL was using some API that requirs higher CAS, in return you could just place your DLL in the GAC instead.

Shai Petel said...

Update for 2010 (perhaps even works on 2007) to get more info on this error here:

most annoying error message in SharePoint