Search Issue Tracker
By Design
Votes
0
Found in
2018.1.0f2
Issue ID
1041417
Regression
No
[IL2CPP] In Standalone builds, IL2CPP is reporting that generics are used when there is none of them
To reproduce:
1. Install Steam on your machine, log in to your account and a key to the game that user sent
2. Download attached project "Test.zip" and open in Unity
3. Open "SampleScene" scene
4. Enter Play mode
5. Observe that in Console window there will be printed "5"
6. Exit Play mode
7. Build and Run project on Windows IL2CPP scripting backend with Development Build checked
8. Press Play button
5. Observe that in Standalone console window there will be two errors:
"NotSupportedException: To marshal a managed method, please add an attribute named 'MonoPInvokeCallback' to the method definition.
at Steamworks.NativeMethods.ISteamClient_SetWarningMessageHook (System.IntPtr instancePtr, Steamworks.SteamAPIWarningMessageHook_t pFunction) [0x00000] in <00000000000000000000000000000000>:0
at Steamworks.SteamClient.SetWarningMessageHook (Steamworks.SteamAPIWarningMessageHook_t pFunction) [0x00000] in <00000000000000000000000000000000>:0
at SteamManager.OnEnable () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.GameObject.Internal_AddComponentWithType (System.Type componentType) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.GameObject.AddComponent (System.Type componentType) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.GameObject.AddComponent[T] () [0x00000] in <00000000000000000000000000000000>:0
at SteamManager.get_Instance () [0x00000] in <00000000000000000000000000000000>:0
at SteamManager.get_Initialized () [0x00000] in <00000000000000000000000000000000>:0
at TestScript.Start () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.GameObject:Internal_AddComponentWithType(Type)
UnityEngine.GameObject:AddComponent(Type)
UnityEngine.GameObject:AddComponent()
SteamManager:get_Instance()
SteamManager:get_Initialized()
TestScript:Start()
(Filename: currently not available on il2cpp Line: -1)"
"NotSupportedException: IL2CPP does not support marshaling delegates that point to generic methods.
at System.Runtime.InteropServices.Marshal.StructureToPtr (System.Object structure, System.IntPtr ptr, System.Boolean fDeleteOld) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.InteropServices.Marshal.StructureToPtr[T] (T structure, System.IntPtr ptr, System.Boolean fDeleteOld) [0x00000] in <00000000000000000000000000000000>:0
at Steamworks.CallResult`1[T].BuildCCallbackBase () [0x00000] in <00000000000000000000000000000000>:0
at Steamworks.CallResult`1[T]..ctor (Steamworks.CallResult`1+APIDispatchDelegate[T] func) [0x00000] in <00000000000000000000000000000000>:0
at LeaderboardManager..cctor () [0x00000] in <00000000000000000000000000000000>:0
at TestScript.Start () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as TypeInitializationException: The type initializer for 'LeaderboardManager' threw an exception.
at TestScript.Start () [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)"
Notes:
- On Mono scripting backend everything works fine
- Forum thread: https://forum.unity.com/threads/notsupportedexception-il2cpp-does-not-support-marshaling-delegates-that-point-to-generic-methods.532402
- A key to the game is in Comments section
Reproduced on Unity 2018.1.0f2, 2018.1.2f1, 2018.2.0b6 and 2018.3.0a1
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
- Inspector elements are rendered twice when the script component is added via drag-and-drop while the HideFlags.HideInInspector property is set
- Error "Light baking failed with error code 5 (Convergence data not available while rendering lightmaps)" thrown in Console when generating lighting for specific GameObjects
- Copy and Paste options for an Animation Property value are disabled in the Right click contextual menu
- Asset is not found when searching the Label "NewLabel" in Search Window
- "Compute dispatch: missing texture ID..." and "Compute dispatch: missing UAV ID..." warnings are thrown after changing the platform in High Definition 3D template
Resolution Note:
In this case, the offending code is: Steamworks.CallResult<Steamworks.LeaderboardFindResult_t>::OnRunCallResult
The fact that this works with Mono is probably a bug, as in general, marshaling of generics should not work for a .NET runtime.
There is some discussion of this issue in the Steamworks.NET issue tracker:
https://github.com/rlabrecque/Steamworks.NET/issues/227
It looks like it might be coming to a resolution. Unfortunately, we can't do anything to handle this from the Unity side.