Lua No such type: loadassembly

647 Views Asked by At

am trying to script using Lua :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LuaInterface;

namespace Scripting {
    public class LuaParser {
        Lua lua;
        string path;

        public LuaParser(string path) {
            this.path = path;
            lua = new Lua();
        }

        public void ParseClass(string ClassName) {
            string p = path + ClassName + ".lua";
            lua.DoFile(p);

        }

        public Lua Parser {
            get {
                return lua;
            }
        }
    }
}
-----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Scripting {
    class Program {
        static void Main(string[] args) {
            LuaParser p = new LuaParser("C:\\Users\\Administrator\\Documents\\Visual Studio 2012\\Projects\\Scripting\\Scripting\\bin\\Debug\\");
            p.ParseClass("test");

        }
    }
}

and test.lua :-

luanet.loadassembly("Scripting");

but it's not working it throws this exception:-

 LuaInterface.LuaException was unhandled
  HResult=-2146232832
  Message=...2012\Projects\Scripting\Scripting\bin\Debug\test.lua:1: No such type: loadassembly
  Source=LuaInterface
  StackTrace:
       at LuaInterface.Lua.ThrowExceptionFromError(Int32 oldTop)
       at LuaInterface.Lua.DoFile(String fileName)
       at Scripting.LuaParser.ParseClass(String ClassName) in c:\Users\Administrator\Documents\Visual Studio 2012\Projects\Scripting\Scripting\LuaParser.cs:line 20
       at Scripting.Program.Main(String[] args) in c:\Users\Administrator\Documents\Visual Studio 2012\Projects\Scripting\Scripting\Program.cs:line 11
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

test.lua , lua51.dll and LuaInterface.dll in the same directory , what am missing here?

2

There are 2 best solutions below

0
On

It is a Lua error when a non type is found; and not a .Net load assembly. It could not find "loadassembly" as specified in your above example. Try giving it a fully qualified name such as "System.Windows.Forms.Form".

0
On

The method is named 'load_assembly'.