UserData.RegisterAssembly() does not work in .Net Standard
The library is targeted to .Net Standard 1.6 and running in .Net Framework 4.6.1 on Windows Server 2016. Calling UserData.RegisterAssembly() results
System.NotSupportedException: 'Assembly.GetCallingAssembly is not supported on target framework.'
I'm having this problem in .NET Standard 2.0 too.
Same in .NET 7
I ran into this error today and i looked at the code inside of: https://github.com/moonsharp-devs/moonsharp/blob/master/src/MoonSharp.Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs#L25
If you look it just checks the .NET version and throws an exception. I'm not sure if this is old code or not but Assembly.GetCallingAssembly is supported in .NET6,
To fix I just called it myself and passed it to the constructor and it worked just fine:
var script = new Script();
script.Options.ScriptLoader = new EmbeddedResourcesScriptLoader(Assembly.GetCallingAssembly());
var result = script.DoFile("Scripts/test.lua");
Console.WriteLine($"Result: {result.String}");
lua:
print('test')
VSCode console outputted test properly.
@xanathar has the most commits on this repo so just pinging you as FYI I think this section of the code I linked above needs to be updated
@GoldenretriverYT also see above