Frage

Ich verwende SharePoint 2007 und Visual Studio 2008. Ich habe in einer vorhandenen Lösung einen benutzerdefinierten Code geändert.Jetzt beendete ich die Entwicklung und versuche, die WSP-Datei zu generieren.Es gibt nur ein Problem.Ich muss eine WSP-Datei mit der CAS-Richtlinie generieren und nicht an den GAC.Die Person, die diese Lösung erstellt hat, tat es mit diesem Szenario:

1) hat den Build-Ausgabepfad auf "80 \ bin" geändert.

2) Machen Sie einen Release-Build

3) Erzeugen Sie ein WSP mit WSP Builder

4) Ändern Sie die Erweiterung der erzeugten WSP-Datei an .cab

5) Extrahieren Sie die CAB-Datei

6) Finden und bearbeiten Sie das Manifest.xml

7) Ändern Sie das Element an: generasacodicetagpre.

8) Speichern Sie die Datei

9) Erstellen von CAB-Dateien

10) Erstellen Sie die WSP-Datei

Jemand hat mir gesagt, dass dies die böse Lösung ist, um dies zu tun.Es sollte mit dem WSPBuilder in der Befehlszeile möglich sein.Kann mir jemand sagen, wie ich das macht?

War es hilfreich?

Lösung

add this just above your public class file!

[SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, Impersonate = true)] 

[SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, ObjectModel = true)]

then let wspbuilder do the rest for you as it will build the xml file for you within the manifest file!

EDIT

The code that follows the call into the Demand method will be executed only if all the callers in the call stack are granted the permission to access the SharePoint object model. Note that this security demand has no impact on the code that comes before the call into the Demand method. The situation would be different if you were to use the declarative security syntax to annotate MyMethod with the SharePointPermissionAttribute metadata attribute:

   [SharePointPermission(SecurityAction.Demand, ObjectModel=true, Unrestricted=true)]
public void MyMethod()
{
   ...
   SPWeb site = SPContext.Current.Web;
   ...
}

in your case its the main class that contains the create child controls method, as an example:

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace test    {

    [SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, Impersonate = true)] 
    [SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, ObjectModel = true)]
    [ToolboxItemAttribute(false)]
    public class VisualWebPart1 : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/test/VisualWebPart1UserControl.ascx";

        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
        }
    }
}

also it depends on what you want visible to the policy? as iv noted within the comment block. To my understanding its just the main class that needs the policy and not every class within the project!

http://msdn.microsoft.com/en-us/library/gg427711(v=office.12).aspx

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top