InvalidOperationException: Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true
valkyrienyanko opened this issue · 6 comments
Issue
Generics are causing the project to crash on startup. Read the following site to get a better idea of why this error is happening https://lostechies.com/patricklioi/2013/12/13/nailing-down-generics/
An issue for this was also created on the Godot repo, which can be found here
Steps to Reproduce
- Download and install either Godot 4 Beta 4 or Godot 4 Beta 5 (make sure you install the c-sharp version of Godot)
- Add the following code to the very beginning of
_PhysicsProcess(double delta)
inMovingEntity.cs
to trigger the dynamic runtime compiler (may not be required, error may happen even without doing this)
int test = 5;
test++;
GD.Print(test);
- Run Godot through cmd with
--verbose
flag - Select and open Sankari project
- Notice the popup and error logs in cmd
Preview of Popup
clicking OK will close the project
Relevant Error Logs
ERROR: System.InvalidOperationException: Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.
at System.Reflection.RuntimeMethodInfo.ThrowNoInvokeException()
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Godot.Bridge.ScriptManagerBridge.GetMethodListForType(Type type) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs:line 761
at Godot.Bridge.ScriptManagerBridge.UpdateScriptClassInfo(IntPtr scriptPtr, godot_bool* outTool, godot_array* outMethodsDest, godot_dictionary* outRpcFunctionsDest, godot_dictionary* outEventSignalsDest, godot_ref* outBaseScript) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs:line 593
at: godotsharp_pusherror (modules/mono/glue/runtime_interop.cpp:1240)
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Godot.NativeInterop.NativeFuncs.godotsharp_internal_reload_registered_script(IntPtr)
at Godot.Bridge.ScriptManagerBridge.CreateScriptBridgeForType(System.Type, Godot.NativeInterop.godot_ref*)
at Godot.Bridge.ScriptManagerBridge.GetOrCreateScriptBridgeForType(System.Type, Godot.NativeInterop.godot_ref*)
at Godot.Bridge.ScriptManagerBridge.GetOrCreateScriptBridgeForPath(Godot.NativeInterop.godot_string*, Godot.NativeInterop.godot_ref*)
Using present mode: VK_PRESENT_MODE_FIFO_KHR
Potential Snippets of Code Causing this Issue
Maybe the abstract
keyword combined with generics is the culprit? (https://developercommunity.visualstudio.com/t/cant-run-tests-late-bound-operations-cannot-be-per/692576)
Closed as seems to have been fixed in Godot 4 beta 8
Re-opening as the issue came back. Exact same popup / error.
Seeing a very similar problem with my project, in my case also an abstract class with a generic parameter, but also partial (inherits from a Godot Node)
I removed the abstract modified and implemented empty virtual methods instead of abstract, and when I opened the project, it was possible to see it for a second, then Godot died again.
I went to Visual Studio, cleaned the solution, tried opening the project again, and it worked.
v4.0.beta10.mono.official [d0398f62f]
If cleaning the solution is like deleting the .godot
folder then the issue may most likely come back later on.
Looks like this issue is going to get fixed :D
godotengine/godot#70511
Appears to be fixed by beta 11. The error did come back but I'm assuming that's just because I didn't delete the .Godot folder. Fingers crossed.