[英]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.