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
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
This is a duplicate of issue #1093274