0

In .net4 the AppDomain.Create methods are marked with the SecuritySafeCritical attribute.

When these methods are invoked inside an environment with medium trust level a SecurityException is thrown (or am I wrong?)

How can I create another AppDomain from within an AppDomain with Medium Trust Level?

Thanasis Ioannidis
  • 2,981
  • 1
  • 30
  • 50
  • 1
    You can't. What exactly are you trying to do - why the need to create a new AppDomain? – Levi Mar 26 '14 at 15:46

1 Answers1

1

Since, as you remark, these methods are marked SecuritySafeCritical, you can't.

You would need a "master" AppDomain that spawns child AppDomains, and that master has to have the top trust level.

But are you sure you need separate AppDomains, and since you are using ASP.NET, can you not just rely on IIS to make sure you get the independence and separation of logic/data/security you need?

If you intend to load and unload assemblies dynamically, you will indeed need to be able to create and destroy separate AppDomains, since there is no way to unload individual assemblies from an AppDomain. Otherwise, you may not even require this (expensive) feature.

Roy Dictus
  • 32,551
  • 8
  • 60
  • 76
  • Side note: I don't think `SecuritySafeCritical` is cause of the restriction. From what I understand it basically says "this method will do all necessary checks itself, anyone can call if" rather than "this call will fail in partial trust". – Alexei Levenkov Mar 26 '14 at 16:01