I have developed a sln that is composed of 3 different web parts. Everything was working fine, but I renamed the project and assembly at the request of conforming to a naming convention. I deleted the web parts from the wp gallery, retracted the sln and redeployed the newly renamed project. When attempting to preview my web parts in the web parts gallery I receive the error:

Microsoft.SharePoint.ApplicationRuntime.SafeControls+UnsafeControlException: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type is not registered as safe.

I have checked the web.config to verify that my web parts are under <SafeControls> and that the namespace is correct. I've checked each web parts .spdata file to check that everything is correct there as well.

Now, I rolled back my sln to the point in time when my project was working (via TFS), deleted the web parts from the gallery, retracted the sln and redeployed once again. I thought reverting back to the working sln would solve my problem, but unfortunately I am met with the UnSafe exception again.

Can anyone provide any further thoughts into my situation? I'm running out of places to look. Thanks!

  • Are the Version & PublicKeyToken numbers the same between the web.config's safecontrol entry and the assemblies in the GAC?
    – Mike Lutge
    Aug 8, 2014 at 18:44
  • @MikeLutge Thanks for the reply. The version & PublicKeyToken between the safecontrol enty and the GAC assembly is the same
    – KidBatman
    Aug 8, 2014 at 19:00

1 Answer 1


You should try delete wsp and install again. We apply this formula and the program was working.

  • Retracting and redeploying the .sln = delete wsp and install again.
    – Jussi Palo
    May 4, 2018 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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