| 675 | #endif |
| 676 | |
| 677 | void MCore::UnloadEngine() |
| 678 | { |
| 679 | // Only root domain should be alive at this point |
| 680 | for (auto domain : MDomains) |
| 681 | { |
| 682 | if (domain != MRootDomain) |
| 683 | Delete(domain); |
| 684 | } |
| 685 | MDomains.Clear(); |
| 686 | |
| 687 | if (MRootDomain) |
| 688 | { |
| 689 | #if PLATFORM_WINDOWS && USE_EDITOR |
| 690 | // TODO: reduce issues with hot-reloading C# DLLs because sometimes it crashes on exit |
| 691 | __try |
| 692 | #endif |
| 693 | { |
| 694 | mono_jit_cleanup(MRootDomain->GetNative()); |
| 695 | } |
| 696 | #if PLATFORM_WINDOWS && USE_EDITOR |
| 697 | __except (MonoHackSehExceptionHandler(nullptr)) |
| 698 | { |
| 699 | } |
| 700 | #endif |
| 701 | Delete(MRootDomain); |
| 702 | MRootDomain = nullptr; |
| 703 | } |
| 704 | |
| 705 | #ifdef USE_MONO_AOT_MODULE |
| 706 | Platform::FreeLibrary(MonoAotModuleHandle); |
| 707 | #endif |
| 708 | |
| 709 | #if PLATFORM_LINUX && !USE_MONO_DYNAMIC_LIB |
| 710 | if (ThisLibHandle) |
| 711 | { |
| 712 | dlclose(ThisLibHandle); |
| 713 | ThisLibHandle = nullptr; |
| 714 | } |
| 715 | #endif |
| 716 | } |
| 717 | |
| 718 | void MCore::CreateScriptingAssemblyLoadContext() |
| 719 | { |