Friday, 5 December 2014

A web part or web form control on this page cannot be displayed or imported. the type could not


Solution:
This is common error if you eg. changed WebPart name after creation and/or changed its namespace.

Since you are working on SharePoint 2010 and most likely with Visual Studio 2010 in VS project:

Option 1
Select your custom webpart
Use right click > Properties
In properties windows under SharePoint find Safe Control Entries
Click ... button
Verify your settings (namespace)

Retract your solution and delete your web part from Web Part Gallery (this can be your first step). Rebuild, package and deploy your project.

You don't need to edit your web.config manually!
Option 2
Since i imported old web part in VS 2010, and i tried to deploy in the same Site collection...I got this error..
I renamed my new project and instead of importing old file, i copied the code and deployed...

It work like a charm..