This exception occurs when this line of code is executed.
retobj = Marshal.PtrToStructure( buffer, anytype );
I don't know what causes this because the application I'm trying to run works fine on other development machines.
public static object RawDeserialize(byte[] rawdatas, Type anytype) { int rawsize = Marshal.SizeOf(anytype); if (rawsize > rawdatas.Length) { return null; } IntPtr buffer = Marshal.AllocHGlobal(rawsize); object retobj = null; try { Marshal.Copy(rawdatas, 0, buffer, rawsize); retobj = Marshal.PtrToStructure(buffer, anytype); } finally { Marshal.FreeHGlobal(buffer); } return retobj; }
I tried to fix the .NET Compact Framework several times and nothing works, does anyone know about this solution?
source share