“A Web Part or Web Form Control on this Page cannot be displayed or imported. The type is not registered as safe.”
I came across such error when I adding a web part into web part page. What I did was just compiling the project with the latest framework my sharepoint using. Of course, I googled this error before I fixed this error, one solution is provided below. It could also solve my problem although i didn’t try it.
Figure 1. To fix the error – The type is not registered as safe.
Some experts from MSDN:
Specifying Safe Web Parts
Allowing users or even members of the Administrator site group to have unrestricted freedom in importing new Web Parts can expose a server to security threats. For this reason, Web Parts must be explicitly designated as safe before they become available on the virtual server. This is done by making entries in the SafeControls section of a Web.config file for the virtual server. The Web.config file is typically found at this location:
system_drive:\Inetpub\wwwroot\Web.config
Each SafeControls entry identifies an assembly that contains one or more Web Parts. You can list Web Part classes individually or you can specify that all Web Parts in the assembly are safe. Here is an example of the SafeControls section from a Web.config file, with tags preceding it that show how it fits into the XML hierarchy of the file:
<configuration>
<SharePoint>
<SafeControls>
<SafeControl Assembly="System.Web, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="System.Web.UI.WebControls" TypeName="*" Safe="True" />
<SafeControl Assembly="System.Web, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="System.Web.UI.HtmlControls" TypeName="*" Safe="True" />
<SafeControl Assembly="Microsoft.SharePoint, Version=11.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c"
Namespace="Microsoft.SharePoint" TypeName="*" Safe="True" />
<SafeControl Assembly="Microsoft.SharePoint, Version=11.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c"
Namespace="Microsoft.SharePoint.WebPartPages" TypeName="*"
Safe="True" />
<SafeControl Assembly="Northwind, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null" Namespace="Northwind"
TypeName="*" Safe="True" />
</SafeControls>
Each SafeControl element has four attributes:
CAUTION If you give a strong name to the sample Northwind assembly by adding the path to a key pair file in the Assemblyinfo.cs file for the project, you must add the public key token to the SafeControl entry for that assembly. An easy way to get a strong-named assembly’s public key token is to add the assembly to the GAC by dragging the .dll file into the local_drive:\Windows\Assembly directory. You can then right-click the assembly and click Properties to see the properties of the assembly. The public key token is displayed, and this view of the token is handy because you can select it and copy it to the clipboard. If you want to remove the assembly from the GAC, right-click the assembly, and then click Delete.
The SafeControls listing prevents rogue Web Parts from becoming available to users. Additionally, Web Parts are subject to the same Code Access Security controls that are applied to all managed code.