neolua icon indicating copy to clipboard operation
neolua copied to clipboard

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

Open ShadowMarker789 opened this issue 3 years ago • 5 comments

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 avatar Jan 06 '22 08:01 ShadowMarker789

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 avatar Jan 06 '22 08:01 ShadowMarker789

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 avatar Jan 06 '22 08:01 ShadowMarker789

Did some testing by cloning and modifying.

Pull request created: Bugfix Pull Request

ShadowMarker789 avatar Jan 06 '22 11:01 ShadowMarker789

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 avatar Jan 12 '22 15:01 Whoome

Nevermind, I see it, there was a missing conditional

Whoome avatar Jan 12 '22 15:01 Whoome