System.AppDomain icon indicating copy to clipboard operation
System.AppDomain copied to clipboard

Expand on your warning?

Open dotnetshadow opened this issue 9 years ago • 1 comments

Hi could you please expand on your warning:

DO NOT USE UNLESS YOU HAVE NO OTHER CHOICE! THINK ABOUT IT! Seriously, using this library is usually a sign that something (cough_dotnetcore_cough) is wrong.

I mean if you need a catch all situation in a console application, what would your suggestion be? Here is an example of a typical usage: https://github.com/dotnet/coreclr/issues/2999

dotnetshadow avatar Jul 10 '16 06:07 dotnetshadow

I admit I might want to flesh that warning out more.

The simplest answer is that this library is using reflection on internal types to work and can break very easily. In it's short existence I have had to make many changes to keep it working as .NET Core has changed under it.

Other reasons to not use this include:

  1. I've done my best to make this code as fast as possible but reflection is still reflection, you will take a speed hit.
  2. As noted by Immo in the post you reference, most of the reasons that a developer would want this library will be exposed by the framework in some new way. So this should only be used when the library hasn't yet.
  3. Most of the features exposed by System.AppDomain should not be needed except in very unique cases. Logging all errors? That should be done by a logging framework that can handle the weirdness that can happen in there. Most of the other members are only useful for fancy reflection usage with most developers will never use.

In your exact case you could simply wrap everything in main in one giant Try/Catch.

shmuelie avatar Jul 11 '16 18:07 shmuelie