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
- Game view renders artifacts when Camera's Component "Post Anti-aliasing" is set to "TAA" and Dynamic Resolution's "Forced Screen Percentage" is changed
- A deactivated Prefab's name color becomes white when a GameObject in the scene is deactivated
- The Game view becomes blank when using Frame Debugger with MSAA and Texture binding enabled in Play Mode
- Crash on dynamixel_sdk.dynamixel:groupSyncReadTxRxPacket when entering Play Mode after updating path to Dynamixel SDK in script
- NullReferenceException is thrown when changing the Inspector preview selection
This is a duplicate of issue #1093274