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
- The tag adder functionality does not work if a space is entered instead of a name
- Errors thrown in the Console when configuring In-App Purchases package
- Longer Scaler Profile names go out of the"Scaler Profilers" section
- AI Navigation window UI elements overlap when the AI Navigation window is docked and resized
- Editor freezes after some time when using NavMeshQuery::Raycast
This is a duplicate of issue #1093274