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.