Execute dll in medium trust

Last post 05-23-2007 11:38 AM by donkiely. 1 replies.

Sort Posts:

  • Execute dll in medium trust

    05-23-2007, 8:10 AM
    • Member
      57 point Member
    • Sleb
    • Member since 02-19-2007, 8:31 PM
    • Posts 55

     Hi,

     I have an application where I need to execute an activeX called  SIPSExec.dll

     
    This is how I execute it

     Dim transaction As New SIPSExec.Execute()
     
    The maximum trust level I can have is Medium so it fails with this error System.Security.SecurityException: System.Security.Permissions.SecurityPermission
     
    Is there an alternative way to execute a dll using medium trust only ?
     
    Thanks 
     
     


     

  • Re: Execute dll in medium trust

    05-23-2007, 11:38 AM
    Answer
    • Star
      14,308 point Star
    • donkiely
    • Member since 06-18-2002, 2:28 PM
    • Fairbanks, Alaska
    • Posts 2,439
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Hi,

    You're having this problem because the Medium trust level doesn't have the Unmanaged Code flag set on the SecurityPermission. In other words, your code is not allowed to call unmanaged code, in this case your ActiveX control. Even the High trust level doesn't have this permission.

    There are two decent options. One is to create a custom trust level that adds the permission to the medium trust level. This isn't hard, but takes a few steps. The downside of this technique is that your entire application then has this dangerous permission. But if you are using this ActiveX component throughout your app this might be a reasonable option.

    The other, better option is to sandbox the dangerous code, which calls this ActiveX component. Put the code that calls it into a separate assembly, grant that assembly either full trust or a custom trust level, and call into that assembly from your Web page code. This option is a bit more involved because now you have partially trusted callers into the sandboxed assembly, which requires a few extra steps.

    The best description I've seen about these techniques is in Dominick Baier's Developing More-Secure Microsoft ASP.NET 2.0 Applications.

    Make sense?

    Don
     

    Don Kiely, MCP, MCSD
    In the Last Frontier, Interior Alaska
    Please post questions and replies to the forum! And remember to MARK AS ANSWER when someone definitively answers a question or resolves a problem!
Page 1 of 1 (2 items)