Why does AppDomain.Unload() error in finalizer?

不羁岁月 提交于 2019-12-06 14:06:16

The AppDomain class does not have a finalizer defined and so will just be garbage collected as normal. The finalizer of your Program class will be called from the finalizer thread of the garbage collector. When this happens, there is no guarantee that your AppDomain instance will or will not have been garbage collected yet and so you will get undetermined behaviour.

I would not bother with the finalizer of Program, as the AppDomain will get garbage collected anyway, plus in addition, the whole process will be destroyed when the Main method exits anyway.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!