Limit component/assembly to use only Medium Trust compatible classes

Z

ZSvedic

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top