Search Issue Tracker
Duplicate
Votes
0
Found in
2018.2.15f1
2018.3.5f1
Issue ID
1126579
Regression
Yes
[Windows][.NET 4.x] Delegate.DynamicInvoke fails with an exception when Scripting Runtime Version is set to .NET 4.x Equivalent
When attempting to use Marshal.GetDelegateForFunctionPointer with the IntPtr returned from "GetProcAddress" (kernal32) when the scripting runtime is set to .NET 4.x Equivalent, the incorrect number of parameters is returned from the delegate's MethodInfo and an exception is raised when calling Delegate.DynamicInvoke when using the correct number of parameters.
To reproduce:
1. Download attached project “DynamicInvoke.zip" and open in Unity
2. Set Scripting Runtime Version to .NET 4.x Equivalent
3. Click on the Custom menu item "Editor/Load Library" and Observe Console
Expected results: The Code shouldn't throw an Exception and the correct number parameters should be returned as part of the delegate's MethodInfo on either runtime
Actual results: In Console, there will be printed Exception:
"Failed to invoke delegate eith error: Number of parameters specified does not match the expected number.
UnityEngine.Debug:LogErrorFormat(String, Object[])
LoadLibraryMenu:LoadDll() (at Assets/Editor/LoadLibraryMenu.cs:66)"
Notes:
- This issue appears only on Windows Editor
- Cannot reproduce on macOS because Unity Editor does not load Library
- This works as expected when the Scripting Runtime Version is set to .NET 3.5 Equivalent
Reproduced on Unity 2018.2.15f1, 2018.2.20f1, 2018.3.6f1, 2019.1.0b4 and 2019.2.0a6
Not reproduced on Unity 2018.2.14f1
Regression on Unity 2018.2.15f1
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Custom ScriptableObject asset in the project setting are not well deserialized during the Reimport All process
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
This is a duplicate of issue #1093274