Saturday, February 12, 2011

How do I set full trust for a single Web Part in SharePoint?

I am looking to set full trust for a single web part, is this possible? manifest.xml maybe?

  • Have you tried registering the assembly in the GAC? This is the preferred approach to giving any assembly full trust on your machine:

    gacutil.exe \i C:\Path\To\Dll.dll
    

    Hope that helps. Let me know if I misunderstood your question.

    naspinski : I am deploying my custom made webparts with a CAB file and 'stsadm -o addwppack', will this be in the GAC? How can I check?
    Ryan : naspinski - probably better to edit your question to clarify the CAB package, people may not see your comment here
  • You can install a CAB packaged web part to the GAC using

    STSADM -o addwppack -filename yourwebpart.cab -globalinstall
    

    If you are using WSP packages you need to set attributes in the manifext.xml file

    <Assembly Location="yourassembly.dll" DeploymentTarget="GlobalAssemblyCache">
    

    and call

    STSADM -o AddSolution -filename yourwebpart.wsp
    
    STSADM -o DeploySolution -name yourwebpart.wsp -allcontenturls -immediate -force -allowGacDeployment
    

    Of course you shouldn't really install to the GAC if you can help it, setting CAS is the preferred way.

    From Ryan
  • As far as I recall manifest.xml is correct, and you specify the CodeAccessSecurity.

    This article has a detailed description about it http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/05/how-to-configure-code-access-security-for-a-web-part.aspx

    when you deploy your solution then you deploy it with the -allowCasPolicies flag on

    I'm not sure i'd want to put a webpart into the GAC

    From thmsn

0 comments:

Post a Comment