locked
Error while deploying a WSP with CAS using the Visual Studio 2010 SharePoint Developer Tools RRS feed

  • Question

  • I’m getting a weird error while trying to Debug a WSP with CAS policies using the Visual Studio 2010 SharePoint Developer Tools. When I press F5 I’m getting the following error:Error occurred in deployment step 'Add Solution': Property set method not found.

    However, when I’m adding and deploying the same WSP through command line it works all fine.

     

    Here’s what I’ve done so far:

    -          I created an Empty SharePoint Project

    -          I’ve set the Assembly Deployment to WebApplication

    -          I’ve added a Web Part with the following code:

     

    [ToolboxItemAttribute(false)]

        public class MyCasWebPart : WebPart

        {

            protected TextBox InputBox;

            protected IButtonControl Button;

     

            protected override void CreateChildControls()

            {

                InputBox = new TextBox();

                Button = new Button()

                {

                    Text = "Click me"

                };

                Button.Click += new EventHandler(Button_Click);

     

                Controls.Add(InputBox);

                Controls.Add((Button)Button);

            }

     

            void Button_Click(object sender, EventArgs e)

            {

                SPWeb web = SPContext.Current.Web;

                SPList tasksList = web.Lists["Tasks"];

                SPListItem item1 = tasksList.Items[0];

                InputBox.Text = item1[SPBuiltInFieldId.Title] as string;

            }

        }

     

    -          Because the Web Part uses SharePoint Object Model and is being deployed to BIN I’ve extended the Package’s Solution Manifest with the following code:

     

    <?xml version="1.0" encoding="utf-8"?>

    <Solution xmlns="http://schemas.microsoft.com/sharepoint/">

    <CodeAccessSecurity>

    <PolicyItem>

    <PermissionSet class="NamedPermissionSet" version="1">

    <IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True" />

    </PermissionSet>

    <Assemblies>

    <Assembly Name="$SharePoint.Project.AssemblyName$" Version="$SharePoint.Project.AssemblyVersion$" PublicKeyBlob="$SharePoint.Project.AssemblyPublicKeyBlob$"/>

    </Assemblies>

    </PolicyItem>

    </CodeAccessSecurity>

    </Solution>

     

    -          From what I’ve seen the manifest is being merged properly.

    -          Now when I press F5 (Debug) I’m getting the error I mentioned before. But if I add and deploy the generated WSP manually through command-line it works all fine.

     

    Am I missing something or is there a bug in the tools when dealing with CAS (the deployment was okay until I added CAS to it)?


    w: http://blog.mastykarz.nl | t: @waldekm | c: http://mavention.codeplex.com | c: http://mavention.nl
    Tuesday, April 20, 2010 4:21 AM

Answers

  • Hi Waldek,

    Yes, this is a known issue.  The package manifest is parsed during the deployment step and this fails when encountering certain manually-added CAS policy elements.  The problem was identified very late in the release cycle and we were not able to address it prior to RTM.  We have published a KB article that contains a workaround:

    http://support.microsoft.com/kb/2022463

    When applied, the workaround enables F5 deployment of projects containing CAS policies.

    -Phil

    Tuesday, April 20, 2010 5:32 PM

All replies

  • Hi Waldek,

    Yes, this is a known issue.  The package manifest is parsed during the deployment step and this fails when encountering certain manually-added CAS policy elements.  The problem was identified very late in the release cycle and we were not able to address it prior to RTM.  We have published a KB article that contains a workaround:

    http://support.microsoft.com/kb/2022463

    When applied, the workaround enables F5 deployment of projects containing CAS policies.

    -Phil

    Tuesday, April 20, 2010 5:32 PM
  • Thanks Phil. Great to hear you guys were able to provide a fix for that that quickly.
    w: http://blog.mastykarz.nl | t: @waldekm | c: http://mavention.codeplex.com
    Tuesday, April 20, 2010 5:34 PM
  • omg, why is there no default stuff in the manifest when changing from GAC to WebApp ?????
    Monday, April 26, 2010 8:55 AM
  • I assume by "default stuff" you mean CAS policies.  What do you think would be the appropriate set of default CAS policies to add to a package when switching an assembly deployment target from GAC to WebApplication?  I would argue that, from a security perspective, there can be no such default set.  That is, each CAS policy should be deliberately added by the developer (and hopefully vetted by the administrators of the target servers) with full knowledge of their intended use and security impact.

    While I am sure that there is a commonly-used set of CAS policies for WebApplication-based SharePoint solutions, and I think it would not be unreasonable for our tools to help developers add them, but it is an entirely different story to have the tools add them itself.

    -Phil

    Monday, April 26, 2010 5:36 PM
  • It could be a commented set of permissions like:

    <?xml version="1.0" encoding="utf-8"?>
    <Solution xmlns="http://schemas.microsoft.com/sharepoint/">
    <CodeAccessSecurity>
      <PolicyItem xmlns="http://schemas.microsoft.com/sharepoint/">
       <PermissionSet class="NamedPermissionSet" version="1" Description="Example">
        <!--<IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True" Impersonate="True" UnsafeSaveOnGet="True" />-->
       </PermissionSet>
       <Assemblies>
        <Assembly Name="SPHelper" />
       </Assemblies>
      </PolicyItem>
     </CodeAccessSecurity>
    </Solution>

    Friday, May 21, 2010 8:53 AM
  • Yes, that would certainly be one option.  However, there are surely many people who are a little, um, "particular" about their source code and loathe having lots of boilerplate in their files.  (I am certainly one of those people.)  There are also many different possible permissions, each with their own set of parameters, some of which likely require project-specific or otherwise deliberate settings.  If we were to provide such commented "templates", we would need to do so such that each were "safe by default" when uncommented but otherwise unchanged; that may not be possible for all permissions.

    Personally, I would much rather see someone take advantage of the SharePoint project system extensibility to provide a more user-friendly means of adding CAS policy items to the Package manifest.  The SharePoint project object model does have programmtic support for manipulating CAS policy items (see http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.sharepoint.packages.ipackagemanifest.policyitems.aspx) upon which a user interface could be built.  (We simply did not have the time or resources to do so in this first version of the SharePoint development tools in Visual Studio 2010).

    -Phil

    Friday, May 21, 2010 10:13 PM