문제

SharePoint 2007 및 Visual Studio 2008을 사용하고 있습니다. 기존 솔루션에서 사용자 정의 코드를 변경했습니다.이제 개발을 마쳤으며 WSP 파일을 생성하려고합니다.1 가지 문제가 있습니다.GAC가 아닌 CAS 정책으로 WSP 파일을 생성해야합니다.이 솔루션을 생성 한 사람 이이 시나리오를 사용하여 수행했습니다.

1) 빌드 출력 경로를 "80 \ bin"로 변경했습니다.

2) 릴리스 빌드

3) WSP 빌더로 WSP 생성

4) 생성 된 WSP 파일의 확장을 .cab 로 변경하십시오.

5) 캡 파일 추출

6) manifest.xml 찾기 및 편집

7) 요소를 다음과 같이 변경합니다.

<CodeAccessSecurity>
    <PolicyItem>
      <PermissionSet class="NamedPermissionSet" version="1" Description="WSPBuilder generated permissionSet" Name="MyCompany.MyCustomer.SharePoint.MySolutionNamed20708d8-8d7f-448d-ae19-52e93e729cc5">
    <IPermission class="AspNetHostingPermission" version="1" Level="Minimal" />
    <IPermission class="SecurityPermission" version="1" Flags="Assertion, Execution, ControlThread, ControlPrincipal" />
    <IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security,  version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True"  UnsafeSaveOnGet="True" Unrestricted="True"/>
</PermissionSet>
      <Assemblies>
        <Assembly Name="MyCompany.MyCustomer.SharePoint.MySolutionName" Version="1.0.0.0" PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010061501CE5D2B707D9EE7AFE461FC262A07CD83D417AE9AC31B142586832A038C385DF5A19C4974B39E0EE5F166B4F9C1707987030522B7B5808D910E6C749BAC97EE79976273BA06516AD5D7DB9DD7C53D8A47B038479E627BB0B2AAE299D6F0C392AF7C00CE42D6A3FB25F391AAC36C5217AE98FBBD18AFE3736905FFF0058A4" />
      </Assemblies>
    </PolicyItem>
  </CodeAccessSecurity>
.

8) 파일 저장

9) CAB 파일 만들기

10) WSP 파일 만들기

누군가가 이것을하기위한 불쾌한 해결책이라고 나에게 말했습니다.명령 줄에서 WSPBuilder에서 가능해야합니다.누군가 가이 일을하는 방법을 말해 줄 수 있습니까?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top