Results 1 to 2 of 2

Thread: [RESOLVED] Sharepoint developpment: CodeAccessSecurity (CAS)

  1. #1

    Thread Starter
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Resolved [RESOLVED] Sharepoint developpment: CodeAccessSecurity (CAS)

    Hi guys,

    I've recently started developing sharepoint tools in a new job and let's just say that it is not that simple :P

    I'm currently building an assembly that needs takes a web service url (aspx) in parameters and retrieves the web service description (wsdl) and returns the name of all the exposed methods and parameters of that web service. The problem I have is that the assembly must have "Full trust" in order to run. I tried setting the web app in full trust, which works, but it is not a good practice. So now I'm trying to set the manifest of my assembly to give my assembly full trust. but I cans seem to find the right syntax to do so. Here's one I tried :

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <Solution xmlns="http://schemas.microsoft.com/sharepoint/">
      <CodeAccessSecurity>
        <PolicyItem>
          <PermissionSet class="NamedPermissionSet" version="1" Name="AllowWebServiceCall">
            <IPermission class="WebPermission" version="1" unrestricted="true"/>
          </PermissionSet>
          <Assemblies>
            <Assembly Name="$SharePoint.Project.AssemblyName$" Version="$SharePoint.Project.AssemblyVersion$" PublicKeyBlob="$SharePoint.Project.AssemblyPublicKeyBlob$"/>
          </Assemblies>
        </PolicyItem>
      </CodeAccessSecurity>
    </Solution>
    But it doesn't work. I've been serching the web for already too long :P Anyways, If this makes sense for anybody, I'm new to those sharepoint things so I know that my explanations might not be very precise, I'd be happy if someone could enlighten me about Code Access Security.

    Here's the exception I get, in attachement, I know that its only a security problem as when I set the web application trust level to "Full" it works well.

    Edit: Another thing I must add, the assembly is currently deployed to the GAC which if I understands well means it i already "full trusted" But it seems that as I'm running a Sharepoint sandbox the sandbox itself can call the assembly but does not have the right permissions for the code that is executed in the DLL's methode that gets the wsdl xml from the webservice.

    thanks.
    Attached Images Attached Images  
    Last edited by stlaural; Jun 21st, 2011 at 03:13 PM.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  2. #2

    Thread Starter
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: Sharepoint developpment: CodeAccessSecurity (CAS)

    OK, after searching like an idiot the whole day about Sharepoint security and CAS I finally figured out that instead of using an XmlTextReader to retrieve the XML from a given URL (which works perfectly in a console app bot not once deployed as a DLL in the GAC from an xbap application) I have to use a WebRequest (FML) (which works in both situation) Why ? I don't know, but it works and don't have to learn the Code Access Security anymore.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width