How do I use CAS Policies?

Mar 24, 2008 at 4:20 AM
From what I understand, WSPBuilder will pick up any CAS method attributes and automatically create a custom CAS config file. I've created a basic search web part, and I've included the attribute at the top of the class:

namespace MyTestWebParts
{
DefaultProperty("Text")
ToolboxData("<{0}:SearchTest runat=server></{0}:SearchTest>")
XmlRoot(Namespace = "MyTestWebParts")
SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, ObjectModel = true)

public class SearchTest : System.Web.UI.WebControls.WebParts.WebPart
//etc.

I don't see any wss_customtrust.config file being created in 12\CONFIG. Am I doing something wrong?

Eric
Apr 5, 2008 at 8:06 PM
you should get <CodeAccessSecurity> tree in manifest.xml

ericmlegault wrote:
From what I understand, WSPBuilder will pick up any CAS method attributes and automatically create a custom CAS config file. I've created a basic search web part, and I've included the attribute at the top of the class:

namespace MyTestWebParts
{
DefaultProperty("Text")
ToolboxData("<{0}:SearchTest runat=server></{0}:SearchTest>")
XmlRoot(Namespace = "MyTestWebParts")
SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, ObjectModel = true)

public class SearchTest : System.Web.UI.WebControls.WebParts.WebPart
//etc.

I don't see any wss_customtrust.config file being created in 12\CONFIG. Am I doing something wrong?

Eric

Coordinator
Apr 11, 2008 at 12:20 PM
Try the new version 0.9.8.0408.
Your dll have to be in the 80\Bin folder in order to get the CAS policy added to the wss_customtrust.config.
There is no need to create CAS policy for a DLL that is deployed to Global Assembly Cache.
Apr 30, 2008 at 3:41 PM
I am using WSPBuilder's "-cleanup false" argument to view the resulting manifest.xml.

As leonidly said, the <CodeAccessSecurity> tree is created. However <IPermission class="SharePointPermission" version="1" ObjectModel="True" /> never changes, even if I apply this attribute to my class: SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = false)

What else is necessary? I want the type's SharePointPermissionAttribute to control the CAS values, but apparently WSPBuilder is not doing that. I am using version 0.9.8.0408.

Thanks,
Robert Claypool, Nashville, TN