| 890 | } |
| 891 | |
| 892 | bool MAssembly::LoadImage(const String& assemblyPath, const StringView& nativePath) |
| 893 | { |
| 894 | // TODO: Use new hostfxr delegate load_assembly_bytes? (.NET 8+) |
| 895 | // Open .Net assembly |
| 896 | static void* LoadAssemblyImagePtr = GetStaticMethodPointer(TEXT("LoadAssemblyImage")); |
| 897 | _handle = CallStaticMethod<void*, const Char*>(LoadAssemblyImagePtr, assemblyPath.Get()); |
| 898 | if (_handle == nullptr) |
| 899 | { |
| 900 | Log::CLRInnerException(TEXT(".NET assembly image is invalid at ") + assemblyPath); |
| 901 | return true; |
| 902 | } |
| 903 | GetAssemblyName(_handle, _name, _fullname); |
| 904 | CachedAssemblyHandles.Add(_handle, this); |
| 905 | |
| 906 | // Provide new path of hot-reloaded native library path for managed DllImport |
| 907 | if (nativePath.HasChars()) |
| 908 | { |
| 909 | StringAnsi nativeName = _name.EndsWith(".CSharp") ? StringAnsi(_name.Get(), _name.Length() - 7) : StringAnsi(_name); |
| 910 | RegisterNativeLibrary(nativeName.Get(), nativePath.Get()); |
| 911 | } |
| 912 | #if USE_EDITOR |
| 913 | // Register the editor module location for Assembly resolver |
| 914 | else |
| 915 | { |
| 916 | RegisterNativeLibrary(_name.Get(), assemblyPath.Get()); |
| 917 | } |
| 918 | #endif |
| 919 | |
| 920 | _hasCachedClasses = false; |
| 921 | _assemblyPath = assemblyPath; |
| 922 | return false; |
| 923 | } |
| 924 | |
| 925 | bool MAssembly::UnloadImage(bool isReloading) |
| 926 | { |
nothing calls this directly
no test coverage detected