AppDomain UnhandledException

后端 未结 2 1718
慢半拍i
慢半拍i 2021-01-17 23:41

I am working on a C# project and want to make use of the UnhandledException event to catch any exceptions I may have missed in my project (hoping there won\'t be any but to

2条回答
  •  没有蜡笔的小新
    2021-01-18 00:31

    It is possible to load an assembly into a different application domain, but as long as you load the assemblies (like class libraries) into the current application domain this will handle the exception.

    Relationship between application domains and assemblies:

    http://technet.microsoft.com/en-us/subscriptions/index/43wc4hhs(v=vs.80).aspx

    For instance, Assembly.LoadFile() or Assembly.Load() will load the assembly into the current app domain.

    Your code could be creating a new app domain with:

    AppDomain.CreateDomain(..) , then it could load assemblies into this domain, which would not be handled by your code.

    If you reference libraries in your project they will be loaded into the current app domain.

提交回复
热议问题