Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We're implementing a custom web part (based on this article) but it throws this error when trying to insert it into the page:

A Web Part or Web Form Control on this Page cannot be displayed or imported, 
the type could not be found or it is not registered as safe.

We created an Empty SharePoint project, added a Web Part Item, copied code from the article, and commented out the GUID. I can post the code of the one *.CS file but didn't want to unless it's useful.

We've followed the instructions in this post. We have the following in the web.config file for this web part:

<SafeControl 
  Assembly="CustomListWeBPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f85e54975c551557" 
  Namespace="CustomListWeBPart.CustomListWebPart" TypeName="*" 
  Safe="True" SafeAgainstScript="False" />

What are we doing wrong? Thanks.

share|improve this question
2  
Post the .webpart file, I'll bet the type name is wrong (doesn't match the safecontrol). –  James Love Dec 18 '11 at 10:31
    
Thanks, James. I think that was it. We did a fresh VS project and the problem went away. –  Alex C Dec 19 '11 at 9:45
1  
Common problem. Always check the .webpart file, then the namespace and class name in the .cs file, and finally click the webpart Folder in the VS Solution, hit F4 to bring up the properties panel, and look athe SafeControls entries to make sure it all matches up. I often rename the namespaces in new webparts so I check all of these when I do. –  James Love Dec 19 '11 at 9:47
    
Thanks, James. If you provide the above as an answer I'll mark it as the correct one :) –  Alex C Dec 19 '11 at 11:27
add comment

1 Answer

up vote 1 down vote accepted

Common problem. Always check the .webpart file, then the namespace and class name in the .cs file, and finally click the webpart Folder in the VS Solution, hit F4 to bring up the properties panel, and look athe SafeControls entries to make sure it all matches up. I often rename the namespaces in new webparts so I check all of these when I do.

share|improve this answer
add comment

Your Answer

 
discard

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.