![](/img/trans.png)
[英]Reading Azure key vault throws exception: System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.'
[英]System.ExecutionEngineException being thrown
执行此代码行时会抛出此异常
retobj = Marshal.PtrToStructure( buffer, anytype );
我不知道是什么原因造成的,因为我试图运行的应用程序在其他开发者机器上工作正常。
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;
}
我已经多次尝试修复.NET Compact Framework,似乎没有任何工作,有没有人知道这个解决方案?
如果您将调试您的程序,您将发现以下行引发异常:
retobj = Marshal.PtrToStructure(buffer, anytype);
主要原因是编组工具不知道如何编组你的类型。 这有很多可能的原因,我知道最常见的两个原因是:
结构中的嵌套结构(类型为anytype)
[StructLayout(LayoutKind.Sequential,Pack = 1)]
嵌套数组。
[MarshalAs(UnmanagedType.ByValArray,SizeConst = 512)]
希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.