neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
472 stars 76 forks source link

.Net 6 - Assembly.ReflectionOnlyLoad always throws exceptions for your classes #142

Closed ShadowMarker789 closed 1 year ago

ShadowMarker789 commented 2 years ago

NeoLua Version: 1.3.14 from NuGet - BUT ERROR ONLY IN .NET 6!

Example to reproduce: ( Lua code that interacts with your own custom classes )

AddChoice = clr.Blithe.VisualNovel.Instance.AddChoice; 
AddChoice("Yes", YesToBeingAHero, true);

Unfortunately Assembly.ReflectionOnlyLoad was obsoleted in .Net 6 as per Microsoft Documentation

As a result This Line of Code always throws an exception on this platform.

Could we perhaps get a platform or runtime check for .Net 6?

ShadowMarker789 commented 2 years ago

I had just recently upgraded my game project to .Net 6 since I wanted to use certain libraries that only work in .Net 6 - turns out the upgrade caused problems for NeoLua.

ShadowMarker789 commented 2 years ago

As it happens if you ignore those exceptions thrown everything continues to work but while it's busy throwing an exception for every assembly loaded we're eating a lot of overhead as a result from the exception unrolling and stack-trace.

ShadowMarker789 commented 2 years ago

Did some testing by cloning and modifying.

Pull request created: Bugfix Pull Request

Whoome commented 2 years ago

I am unable to get this to compile under .NET 6. The line that includes "CompileToMethod" seems to not compile as that method does not exist. How did you solve that problem?

Whoome commented 2 years ago

Nevermind, I see it, there was a missing conditional