SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I keep getting this error when I try to add a web part that I added through a WSP:

A Web Part or Web Form Control on this Page cannot be displayed or imported. The type is not registered as safe.

I installed this through the Management Shell:

Install-SPSolution -Identity mySolution.wsp -WebApplication http://sp-dev:10000 -GACDeployment

Is there something I need to do differently with my WSP in order to get this error message to go away? I would prefer a solution that allows me to solve this through my WSP if possible.


Ok, I marked the additional assembly as a Safe Control and now my manifest looks like this. I noticed that the Safe Controls node under my third party assembly (DocX.dll) is the same as my Safe Control node under my main project (except for namespace). Is this correct?

    <Assembly Location="DocX.dll" DeploymentTarget="GlobalAssemblyCache">
        <SafeControl Assembly="MyProject, Version=, Culture=neutral, PublicKeyToken=161g332b2e4d265e" Namespace="Novacode" TypeName="*" />
    <Assembly Location="MyProject.dll" DeploymentTarget="GlobalAssemblyCache">
        <SafeControl Assembly="MyProject, Version=, Culture=neutral, PublicKeyToken=161g332b2e4d265e" Namespace="MyProject.MyProject" TypeName="*" />
share|improve this question
Is there a Strong Name Key (.snk) in your project that is being used to sign your assemblies? – Tim Gabrhel Apr 20 '11 at 4:19
Yes, I have that already. – Abe Miessler Apr 20 '11 at 5:05
it is cause usually by renaming a webpart and its classes by hand. add a clean Visual Webpart and copy paste the main ascx and codes – imanabidi Jul 2 '14 at 4:37
up vote 9 down vote accepted

Sounds like you are missing the <SafeControl> element from your package. Normally it is added for you if you create it in VS2010. But if your web part/control is in another assembly you may have to add it manualy

Something like this should go in your Package.Template.xml file (Solution explorer -> Package -> Open -> Manifest -> Edit Options)

             Assembly = "Text"
             Namespace = "Text"
             Safe = "TRUE" | "FALSE"
             TypeName = "Text"/>

Can you tell us a little about what controls/webparts are in the wsp?

Example default package preview has this:

<Solution xmlns="" SolutionId="7905031d-87a1-47b3-b631-c93daff7e4c7" SharePointProductVersion="14.0">
    <Assembly Location="SharePointProject1.dll" DeploymentTarget="GlobalAssemblyCache">
        <SafeControl Assembly="$SharePoint.Project.AssemblyFullName$" Namespace="SharePointProject1.WebPart1" TypeName="*" />
    <FeatureManifest Location="SharePointProject1_Feature1\Feature.xml" />
share|improve this answer
There is only one visual web part in the WSP, but it IS using a third party assembly for some functionality. I added that to my "Additional Assemblies" and I notice that it has "No" set under Safe controls. Could this be the problem? – Abe Miessler Apr 20 '11 at 4:57
if the visual webpart uses controls in the third party assembly, then yes. Remember that the Assembly property needs to be the FullName (including the version etc) – djeeg Apr 20 '11 at 5:16
Awesome, take a look at my update. Does that look correct? – Abe Miessler Apr 20 '11 at 5:31
the first Assembly should be the FullName of DocX.dll – djeeg Apr 20 '11 at 7:06

Visual Studio has a bug where changing the namespace of your class does not update the manifest file of the installation package. Then when you install the safe control and execute your webpart, it is missing due to a namespace mismatch.

For example:

<SafeControl Assembly="Sharepoint_Native_Indicators, Version=,
                       Culture=neutral, PublicKeyToken=cd7250552f7daf2e"
             Namespace="XXXXX.YYYYYY" TypeName="*" />
share|improve this answer

Dont forget to check the SharePointProjectItem.spdata file too. Most of them miss this. The namespace here may not get updated if you changed it in just the code files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.