I have created a feature that contains 4 web parts. The feature is working great on my dev environment so I am trying to move it over to production. I added and deployed the feature without incident and 2 of the 4 web parts can be added to pages fine. The other 2 produce the following error:
Unable to add selected web part(s). (Web Part Name): 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.
The web parts are fairly similar, they contain textboxes, dropdowns, and peopleeditors, nothing special. All 4 show up in the web part gallery. I have the following entry in my web.config:
<SafeControl Assembly="xxx_WebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=274c568f7ef9ca81" Namespace="xxx_WebPart.UI.WebControls.WebParts" TypeName="*" Safe="True" />
I've been searching on the error but most hits seem to point to the web.config entry which I have. I'm stumped as to why 2 of the 4 web parts are working and the others aren't. Any help would be appreciated!
Are the two that are failing using some other control or library? Any UI control referenced and rendered has to be added to the safe controls. If you're using a 3rd party DLL that wasn't packaged properly or is using controls not marked as safe then you'll see this issue.
Try looking at the webpart XML as well and make sure you're referencing the right DLLs (this can get out of sync if you refactor class/namespace but don't edit the webpart to match). In this case your webpart would still show in the gallery (it's just XML after all; no problem there) but trying to use it would throw this error due to the webpart trying to reference a DLL that wasn't registered (and likely doesn't exist). If this is the trouble you should deactivate the feature, ensure the webpart is deleted from the gallery then deploy your changes and reactivate. You can view the webpart XML from the browser to see that it's been updated/corrected.