CSLua is a pure C# library for interfacing to the Lua 5.1 Windows DLL. It supports the core Lua API and includes a C# class wrapper for using C# objects from Lua script. I built this for fun to learn more about Lua and C# and thought I would share it.

The code is now available on GitHub.

Lua Binaries can be downloaded from luabinaries
Lua Binaries Download

Documentation about Lua
Lua Reference Manual

lib/CSLua/LuaDLL.cs contains the marshalling definitions to the standard Lua API.

lib/CSLua/LuaState.cs is a class wrapper for a lua state and an API for registering C# objects and functions with Lua.

samples/CSLuaSampleApp/MainWindow.xaml.cs contains an basic interactive Lua interface with a test suite of C# classes and methods.

samples/test/data/test.lua contains a Lua script that is designed to stress test the test objects in MainWindow.xaml.cs.


  • Mostly complete standard Lua C API exposed to C#
  • Some additional features for supporting C# features, such as variable arguments
  • C# class wrapper of lua state
  • Support for registration of C# methods as global Lua functions
  • Support for registration of C# objects, either as global objects or returned from methods
  • Automatic registration of class when objects are registered or returned

Future features:

  • Make Lua tables available to use as native C# objects