Limit component/assembly to use only Medium Trust compatible classes

Discussion in 'ASP .Net Security' started by ZSvedic, Aug 25, 2009.

  1. ZSvedic

    ZSvedic Guest

    Hi,
    I am developing a custom .NET component that will be used from both
    desktop apps (WPF, WinForms) and from ASP.NET. I want to make sure
    that component will work in ASP.NET Medium Trust.
    How to set assembly-level security permission so it throws an error if
    ANY of used classes in an assembly requires more than Medium Trust?
    Ideally we want to set something in AssemblyInfo.cs or project
    settings that will cause compiler to report "Class XY is not
    compatible with Medium Trust".
    Before you answer note few things:
    1) Since our DLL is NOT an web application, we can’t set web.config
    file to " <trustLevel name="Medium".."
    2) Having a unit test that is a web application configured for Medium
    Trust is not satisfactory because it will throw an exception ONLY if
    problematic code is executed. We made that mistake on previous
    project; we realized it is not compatible with Medium Trust only when
    somebody clicked on advanced option!
    3) Something like "[assembly: PermissionSetAttribute
    (SecurityAction.PermitOnly, Name="MediumTrust")]" is not possible
    because SecurityAction.PermitOnly can’t be used on assembly.
    Regards,
    Zeljko
    ZSvedic, Aug 25, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Hatcher

    Medium Level Trust and Reflection

    Paul Hatcher, Feb 25, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    485
    Paul Hatcher
    Feb 25, 2005
  2. Michael Howes
    Replies:
    0
    Views:
    491
    Michael Howes
    Jan 26, 2006
  3. =?Utf-8?B?TWFyayBMZWlzdG5lcg==?=

    Does GridView.DataBind work under medium trust with custom objects

    =?Utf-8?B?TWFyayBMZWlzdG5lcg==?=, Aug 22, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    512
    =?Utf-8?B?TWFyayBMZWlzdG5lcg==?=
    Aug 23, 2006
  4. Andy
    Replies:
    1
    Views:
    344
  5. Linda
    Replies:
    1
    Views:
    546
    Dominick Baier
    Aug 31, 2006
Loading...

Share This Page