sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.68k stars 642 forks source link

Unity IL2Cpp throw System.NotImplementedException #1122

Closed ZhanPeng closed 5 years ago

ZhanPeng commented 5 years ago

I use SharpDX.DirectInput in Unity. Today, I need IL2Cpp Project. but IL2Cpp say

IL2CPP error for method 'System.Void SharpDX.Utilities::Read(System.IntPtr,T&)' in assembly 'C:\Workspace\Unity\aicfve-previz\PrevizUnityEditor\Temp\StagingArea\Data\Managed\SharpDX.dll'
Additional information: Build a development build for more information. NotImplementedException

Next, I check SharpDX source code

public unsafe static void Read<T>(IntPtr source, ref T data) where T : struct
    {
        data = *(T*)(void*)source;
    }

In the first time , I want remove this code, but when I check using .the bad thing for me.

Usages Of 'Read<T>(...)'

Get<T>(int):T (in SharpDX.DataBuffer)
GetDataAs<T>():T (in SharpDX.Multimedia.RiffChunk)
GetCurrentState(ref T):void (in SharpDX.DirectInput.CustomDevice)

SharpDX class used Read function.

public unsafe void GetCurrentState(ref T data)
    {
      int num = Utilities.SizeOf<TRaw>();
      byte* numPtr = stackalloc byte[num * 2];
      TRaw data1 = default (TRaw);
      this.GetDeviceState(num, (IntPtr) ((void*) numPtr));
      // here!!!
      Utilities.Read<TRaw>((IntPtr) ((void*) numPtr), ref data1);
      data.MarshalFrom(ref data1);
    }

how I solve problem. Thank you.

jkoritzinsky commented 5 years ago

@xoofx you have any ideas?

xoofx commented 5 years ago

how I solve problem. Thank you.

It is a problem with IL2CPP, you have to contact Unity IL2CPP and send a bug to them (via the forum)