0

If I start console, wpf or asp.net application, will .Net create any AppDomain? Could I assume that there is always exactly one AppDomain?

spiaire
  • 3
  • 3

2 Answers2

1

Yes for a console mode app and a WPF app. It is murkier for an ASP.NET app, it uses appdomains to isolate web sites. And a web site can migrate from one to another when it shadow-copies assemblies.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
0

Yes, there is always one, unless you, or any third party library you use, creates new AppDomains.

According to MSDN an AppDomain is an

isolated environment where applications execute

This might be useful when your software loads some untrusted assemblies as add-ins for example. You could create a secundary AppDomain, load the untrusted assemblies in there, and execute their methods, without having the risk it tempers your original AppDomain.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325