MCPcopy Create free account
hub / github.com/Tencent/xLua / LoadAssembly

Function LoadAssembly

Assets/XLua/Src/StaticLuaCallbacks.cs:807–845  ·  view source on GitHub ↗
(RealStatePtr L)

Source from the content-addressed store, hash-verified

805 }
806
807 [MonoPInvokeCallback(typeof(LuaCSFunction))]
808 public static int LoadAssembly(RealStatePtr L)
809 {
810#if UNITY_WSA && !UNITY_EDITOR
811 return LuaAPI.luaL_error(L, "xlua.load_assembly no support in uwp!");
812#else
813 try
814 {
815 ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
816 string assemblyName = LuaAPI.lua_tostring(L, 1);
817
818 Assembly assembly = null;
819
820 try
821 {
822 assembly = Assembly.Load(assemblyName);
823 }
824 catch (BadImageFormatException)
825 {
826 // The assemblyName was invalid. It is most likely a path.
827 }
828
829 if (assembly == null)
830 {
831 assembly = Assembly.Load(AssemblyName.GetAssemblyName(assemblyName));
832 }
833
834 if (assembly != null && !translator.assemblies.Contains(assembly))
835 {
836 translator.assemblies.Add(assembly);
837 }
838 return 0;
839 }
840 catch (System.Exception e)
841 {
842 return LuaAPI.luaL_error(L, "c# exception in xlua.load_assembly:" + e);
843 }
844#endif
845 }
846
847
848 [MonoPInvokeCallback(typeof(LuaCSFunction))]

Callers

nothing calls this directly

Calls 4

luaL_errorMethod · 0.80
FindMethod · 0.80
lua_tostringMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected