views:

4352

answers:

4

I have a SharePoint web part (essentially just a "Hello World" app) that I just created and am having a problem deploying it. I have signed the .dll, created the .dwp, and registered it as a safe control in web.config. I am able to add it to the Web Part Gallery and add the details for it; however, when I attempt to add it to a page, I get the following error:

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.

Following is my .dwp file:

<?xml version="1.0"?>
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"&gt;
   <Assembly>SimpleWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=################</Assembly>
   <TypeName>MyWebParts.SimpleWebPart</TypeName>
   <Title>My Simple Web Part</Title>
   <Description>A simple Web Part</Description>
</WebPart>

and the entry I added to web.config:

<SafeControl Assembly="SimpleWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=################" Namespace="MyWebParts" TypeName="*" Safe="True" />

I also tried using wildcards for the namespace, which didn't help. I have even tried setting the web.config trust level to "Full" (which I would never do in production, but tried to attempt to narrow down the problem) and still had no luck. Any ideas? Thanks.

+2  A: 

Make sure that you have the Web Part class as Public, might sound silly but I faced once. Also try to populate the web part from the Web part Gallery .

Kusek
I did double-check that, and the class it uses is indeed public. Being as it is manually installed, it already shows up in the gallery itself, and I can't populate it from the "New Web Parts" section.
Geo Ego
not quite my problem but close enough for me to look in the right direction, thank you!
Rob
+2  A: 

Did you try deploying it to the GAC?

IrishChieftain
My first thought - where is the DLL on the server? Local bin directory or the GAC?
Greg Hurlman
The .dll is located in the bin directory on the SharePoint server. I tried installing the .dll to the WINDOWS\assembly directory, and though it installed fine, I still was unable to add the control to a page. I am working with SharePoint on a specific port (one other than 80) and assumed that I could install the .dll to the \bin\ directory in the folder for that port, but there's no joy either way.
Geo Ego
I do not understand why I'm not seeing the .dll in the "New Web Parts" section when I move it to WINDOWS\Assembly. It should show up in the list so that I can populate my Web Parts gallery with it, shouldn't it?
Geo Ego
I ended up having success by using the SharePoint SmartTemplates tool made available through CodePlex. I would still like to know why I am unable to achieve this manually, but for now I am able to continue this project so I'll look into it later. Thanks to everyone for the help.
Geo Ego
Geo, I answered a similar question here:http://stackoverflow.com/questions/1754006/is-sharepoint-local-bin-deployment-possible/1757444#1757444
IrishChieftain
A: 

Geo,

It's been a while since I worked with Web Parts but I laid out the steps here:

http://www.codersbarn.com/?tag=/webpart

Maybe there's something there that can help.

Anthony :-)

IrishChieftain
You've got some interesting points in that article that I hadn't yet been exposed to, particularly some of the settings in web.config that can cause problems. Thanks for the link!
Geo Ego
+1  A: 

Are you deploying your webpart using a SharePoint Solution (.wsp file)? Check out WSPBuilder if you aren't. We also use SharePoint Installer Between the two, a lot of the problems (whether stemming from human error or otherwise) in deployments, like your problem have been resolved in our environment.

Kyle Trauberman
The SharePoint SmartTemplates that I'm using make use of the WSPBuilder and SharePoint Installer. They are awesome tools and cleared my problem up right off the bat. Thanks!
Geo Ego
Being as there are so many people who are having this problem, I thought I would provide a link to SharePoint SmartTemplates as well: http://smarttemplates.codeplex.com/Wikipage. It's a fantastic tool that takes advantage of both the WSPBuilder and SP Installer, and makes deployment completely painless and consistent.
Geo Ego