Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import() Method is not available #9

Closed
nrother opened this issue Mar 5, 2014 · 1 comment
Closed

import() Method is not available #9

nrother opened this issue Mar 5, 2014 · 1 comment
Labels

Comments

@nrother
Copy link
Owner

nrother commented Mar 5, 2014

This code should work, but won't:

import("System.Windows.Forms")
form = Form()
form:ShowDialog()

DynamicLua does not call the method LoadCLRPackage() of NLua, therefore acessing or even importing the CLR classes does not work.

This is a workarround/hack to fix it:

var internalLua = typeof(DynamicLua.DynamicLua).GetMethod("get_LuaInstance", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(lua, new object[0]);
Type luaType = internalLua.GetType();
luaType.GetMethod("LoadCLRPackage").Invoke(internalLua, new object[0]);

This is a pretty nasty bug, since this is one of the really cool features of NLua 😦

@nrother nrother added the bug label Mar 5, 2014
@nrother nrother closed this as completed in 7b87568 Mar 5, 2014
@nrother
Copy link
Owner Author

nrother commented Mar 6, 2014

Until the fix is included in the NuGet package: You can always use luanet:

luanet.load_assembly("System.Windows.Forms")
Form = luanet.import_type("System.Windows.Forms.Form")
form = Form()
form.Text = "This is a cool dialog"
form:ShowDialog()
form = nil

Not so cool as the import() way, but it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant