When i deploy my Custom WebPart in Dev Environment i got error "Cannot import webpart". This is what I finally figured:
- Ensure your feature actually contains the correct version of webpart/assembly.
- Ensure safecontrol is correctly defined with correct version
- Now, Delete all your solution related webparts from the webpart gallery. (This is what really helped me). You can use a ps script for that.
- Redeploy solution. (This will activate the features, but not add the webparts to webpart gallery).
- Deactivate the webpart feature either via UI or Disable-SPFeature command (i used ps)
- Activate the webpart feature (Enable-SPFeature). This will bring all the new updated webparts to the web part gallery.
- Check if the trust level in your web.config file is set to “WSS_Minimal” ? If so, you will have to set it to “medium” as follows:
<trust level="WSS_Medium" originUrl="" />