Unable to add selected web part(s).
Every once in a while when you create a web part or upgrade web part, or do some of things developers do when developing web parts, there comes the chilling moment, when you see an error message such as the one below:
So the question is what do we do in this case? Before you hit the discussion boards, or worse, start pulling your hair, here are couple of tips you can use to troubleshoot the issue:
- Make sure the control is registered as safe in the web.config (duh...actually the error says what it means, right)
- Make sure the assembly is accessible and in the [port]bin folder. (obvious, but worth mentioning)
- Make sure the assembly name in the *.webpart definition file, matches the assembly name in the safe control element in web.config
- Make sure you don't have more than one *.webpart file for the same web part in the web part catalog. This may happen if you changed the name of the *.webpart file.
- Restart IIS to start clean. Attach the debugger to the w3wp.exe process and try to load the page with the rogue web part. This way you can determine the exact location of the assembly you are loading.
- Check if the web part class exists by opening the assembly with reflector. This might sound funny, but in a bigger team, when different versions of assemblies are flying around it is very easy to overlook something and to use the wrong version, which so happens does not contain the web part class at all.
- If you have other tips or suggestions, please add them as comments.
Phew, I think I dodged that one... It turned out I got an older version of the assembly and my web part class was not even there.
Dovizhdane!
Unable to add selected webpart(s). A Web Part or Web Form Control on this page cannot be displayed or imported. The type could not be found or it is not registered as safe.




10 comments:
Check that you accidentially forgot to declare the web part as public ;-)
Check that the code you run has enough rights as defined in the CAS policy / trust level.
Often you start developing a blank web part, and everything looks fine, but as you add code that demands higher CAS privileges the code might fail when you remove and re-add the web part.
Hi Mikhail....
I am also getting this type of error .....but my error is something different from this....
"Unable to add selected web part(s).
HelloWorld: Exception occured. (Exception from HRESULT: 0x8002009 (DISP_E_EXCEPTION))
this is my error....when i m adding a simple Hello Webpart it shows me this exception
Did you try any of the above tips? Do they work?
Hi Mikahil
I have checked the tips u have given........but its all fine at my side.....
what i have done....is I am adding two webparts in PageLayouts in some aspx page.....and i create connection between them in same aspx page.....my connection works fine.....but the Webpart Menu is not showing up ("Minimize","Close").....and if i want to add any other Webpart by Clicking on Add Webpart in Webpartzone then it show an error.....Unable to Add Selected webpart.This webpart is deleted by other user.
i can't figure out what's the problem is.......
Where do you store your page. Do you provision it in the web site, do you create it in a document library, or you use an aspx page in the _layouts folder?
I have same problem with MOSS 2007 on my server machine. “Unable to add selected web part(s)”. Strange thing is that I cannot add web part when I access my page over my public IP, and from local that’s no problem. Another strange thing is that this is the case with Microsoft build in web parts and mine custom ones, but not with KWizCom web parts. If this is permission problem I’m not sure where to look next. I think I have checked everything possibly regarding permissions. One more thing, installation is completely new, server 2003, sql 2005 and moss 2007 all just few days old .
Are you sure your web part does not require specific CAS configuration? One quick way to see if that's the issue is to change the trust level to Full and run your web parts. If that's the case analyze your assembly and create proper CAS policies or use WSPBuilder, which does that for you.
Well the problem is that neither custom nor build-in web parts are able to be added on page. It’s completely new installation at the moment, with no custom web parts deployed. Just those build-in by Microsoft as part of MOSS 2007. The strange thing is that everything was working fine until one day, then no more web parts couldn’t be added over internet. Now we have followed previous procedure of installation. New HDD, formatted, with new windows 2003 installation, all required installations have been made, but now we can’t add web parts from start. Also, at this time only administrator is active user on MOSS on that machine…so first I would like to know is it normal that as administrator, with all full permissions I’m not able to add web parts from start.
nebojsa, why don't you try to post this to one of the SharePoint usergroups. There are many people that track these and that can give good suggestions. From your description it could be an issue with the way you setup your service accounts, but it's hard to tell.
Post a Comment