Unable to add selected web part in VS2010 SP2007 project

Jul 19, 2011 at 11:41 AM
Edited Jul 19, 2011 at 7:43 PM

Hello all.

I'm having problems adding a very simple web part - created with SPSF - to a page. I get the (in)famous error:

"unable add selected web part
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"

I created a SP2007 SPSF Application, then added the SharePoint WebPart artifact, then left it as it comes out from the template. I've also tried adding a simple Label during CreateChildControls.

I tried both with and then without Resources, and both with GAC and Bin deployment. Anyway with no luck.

I checked web.config and wss_custom_wss_minimaltrust: they seem to have the correct SafeControl and PermissionSet entries... and anyway they are generated by SPSF.

The SP 2007 server is remote, so the deploy process goes like this:

1. build solution in VS2010
2. get WSP from ...\ApplicationDeployment\Output\Debug\\\Solutions
3. copy WSP over SP server by remote desktop
4. run stsadm -o addsolution .... successfully
5. deploy solution from Admin portal in IE
6. activate feature on site collection from Site Settings in IE
7. preview the web part from the site web part gallery, or try to add it to a page

I basically did nothing on the Visual Studio/ SPSF side of things. Just left all as it is.

Is there anything you can suggest? Thanks all

EDIT: Note: The problem occurs when adding a SharePointWebPart artifact. It does NOT happen when adding an ASPNetWebPart artifact. Thus: changing item is fine for me, but maybe this could be an open issue for SPSF. Please let me know if you need more info.

Coordinator
Jul 28, 2011 at 3:02 PM

Hey GiUmaTo,

thanks for the input. I will look into.
Have you looked into the manifest.xml of the WSP file if everything is set right for safe control entries? 

Seems like this is the problem.

Could you post the first 20 lines of your manifest.xml?

Thx

Matt

BTW: The application Deployment project is meant to ease the deployment process
Just copy the folder \ApplicationDeployment\Output\Debug to your server and run StartDeploy.bat

The deployment process will check all required prerequisites and logs the progress.
You can even add your feature activation tasks in the ParametersDefault.msbuild and also parameterize the urls depending on the machine or the current user (see examples in MSBuild files)

 

Jul 30, 2011 at 7:13 PM

Hello matein78

thanks for your feedback.

I double-checked the security side of things several times, and also asked the help of another couple of eyes, but to no luck. We checked both the wss_custom_wss_minimaltrust file and the web site web.config file, and everything seems fine.

It may be worth mentioning that the server is a win 2008 (non R2), with WSS 3.0 (not SP server).

Thanks also for the suggestion about Deployment project. At some point I realized it on my own an started using deployment scripts, and I've added feature activation too.

Anyway, here are the manifest first (25) lines:

 

<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="4853aaf0-1301-4253-9180-4f3983b89709">
  <CodeAccessSecurity>
    <PolicyItem>
      <PermissionSet version="1">
        <IPermission class="SharePointPermission" version="1" ObjectModel="True" />
        <IPermission class="WebPartPermission" version="1" Connections="True" />
        <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SkipVerification" />
        <IPermission class="SmtpPermission" version="1" Access="Connect" />
        <IPermission class="AspNetHostingPermission" version="1" Level="Minimal" />
        <IPermission class="SecurityPermission" version="1" Flags="Execution" />
      </PermissionSet>
      <Assemblies>
        <Assembly Name="G0.SampleWP2007.InGAC" Version="1.0.0.0" PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010023AE1E22EDCD17CAFB1E1C856B20101988EFB0DB773001B1D0D9FCA32F138EFB874A0C4AF80654ACA66ACCD8DA78C350C59F1058D6B4EA8BCA1ED08C9A469E6D5E6317A20A7B70EF2E4ED1C5679E302061A0FCABD14724010EFB087137BB37F6B10F836FFF25AA24ECE441C4BD2E35836135E63BA8CD47C41235788E74A4D9C6" />
      </Assemblies>
    </PolicyItem>
  </CodeAccessSecurity>
  <Assemblies>
    <Assembly Location="G0.SampleWP2007.InGAC.dll" DeploymentTarget="GlobalAssemblyCache">
      <SafeControls>
        <SafeControl Assembly="G0.SampleWP2007.InGAC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=807522c60cfb98bb" Namespace="G0.SampleWP2007.InGAC" TypeName="*" />
      </SafeControls>
    </Assembly>
  </Assemblies>
...
</Solution>

Thanks for your attention