导致vshost.exe致命错误的原因是什么?

时间:2017-08-10 13:23:16

标签: c# visual-studio fatal-error

我的程序出现以下错误:

FatalExecutionEngineError occurred
Message: Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'C:\Users\phill\Documents\Visual Studio 2015\Projects\SkyLife Projects\SkylifeRadioApplication\SkylifeRadioApplication\bin\Debug\SkylifeRadioApplication.vshost.exe'.
Additional information: The runtime has encountered a fatal error. The address of the error was at 0x7168e573, on thread 0x24ac. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

我不确定在我的C#应用​​程序中可能导致此错误的原因。我想发布代码,但这个错误似乎很随机,有时会发生在我只是移动应用程序窗口时。我真的想在这里发布一些代码,但问题是,它碰巧在随机时间出错。 Haven并没有指出一种可靠的方法来生成代码。我道歉。

我想知道,代码中可能导致此错误发生的常见问题是什么?我可以实施哪些常见解决方案。 (另外调试技术也非常有用,因为我不确定从哪里开始调试这样的问题!)

编辑:

事实证明我确实有一些我可以发布的消息来源。我正在使用第三方提供的DLL和c#源。源代码使用DLLImport(它不是一个兼容的dll文件,我可以通过引用简单地导入它)。以下是访问C#源中的dll的方法:

[DllImport("SLABHIDDevice.dll")]
public static extern uint HidDevice_GetNumHidDevices(ushort vid, ushort pid);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetHidString(uint deviceIndex, ushort vid, ushort pid, byte hidStringType, StringBuilder deviceString, uint deviceStringLength);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetHidIndexedString(uint deviceIndex, ushort vid, ushort pid, uint stringIndex, StringBuilder deviceString, uint deviceStringLength);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetHidAttributes(uint deviceIndex, ushort vid, ushort pid, ref ushort deviceVid, ref ushort devicePid, ref ushort deviceReleaseNumber);

[DllImport("SLABHIDDevice.dll")]
public static extern void HidDevice_GetHidGuid(ref Guid hidGuid);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetHidLibraryVersion(ref byte major, ref byte minor, ref int release);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_Open(ref IntPtr device, uint deviceIndex, ushort vid, ushort pid, uint numInputBuffers);

[DllImport("SLABHIDDevice.dll")]
public static extern int HidDevice_IsOpened(IntPtr device);

[DllImport("SLABHIDDevice.dll")]
public static extern uint HidDevice_GetHandle(IntPtr device);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetString(IntPtr device, byte hidStringType, StringBuilder deviceString, uint deviceStringLength);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetIndexedString(IntPtr device, uint stringIndex, StringBuilder deviceString, uint deviceStringLength);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetAttributes(IntPtr device, ref ushort deviceVid, ref ushort devicePid, ref ushort deviceReleaseNumber);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_SetFeatureReport_Control(IntPtr device, byte[] buffer, uint bufferSize);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetFeatureReport_Control(IntPtr device, byte[] buffer, uint bufferSize);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_SetOutputReport_Interrupt(IntPtr device, byte[] buffer, uint bufferSize);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetInputReport_Interrupt(IntPtr device, byte[] buffer, uint bufferSize, uint numReports, ref uint bytesReturned);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_SetOutputReport_Control(IntPtr device, byte[] buffer, uint bufferSize);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_GetInputReport_Control(IntPtr device, byte[] buffer, uint bufferSize);

[DllImport("SLABHIDDevice.dll")]
public static extern ushort HidDevice_GetInputReportBufferLength(IntPtr device);

[DllImport("SLABHIDDevice.dll")]
public static extern ushort HidDevice_GetOutputReportBufferLength(IntPtr device);

[DllImport("SLABHIDDevice.dll")]
public static extern ushort HidDevice_GetFeatureReportBufferLength(IntPtr device);

[DllImport("SLABHIDDevice.dll")]
public static extern uint HidDevice_GetMaxReportRequest(IntPtr device);

[DllImport("SLABHIDDevice.dll")]
public static extern int HidDevice_FlushBuffers(IntPtr device);

[DllImport("SLABHIDDevice.dll")]
public static extern int HidDevice_CancelIo(IntPtr device);

[DllImport("SLABHIDDevice.dll")]
public static extern void HidDevice_GetTimeouts(IntPtr device, ref uint getReportTimeout, ref uint setReportTimeout);

[DllImport("SLABHIDDevice.dll")]
public static extern void HidDevice_SetTimeouts(IntPtr device, uint getReportTimeout, uint setReportTimeout);

[DllImport("SLABHIDDevice.dll")]
public static extern byte HidDevice_Close(IntPtr device);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_GetNumDevices(IntPtr device);


/* For the UART portion */
[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_GetNumDevices(ref uint num, uint vid, uint pid);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_GetString(UInt16 deviceNum, uint vid, uint pid, char[] name, UInt16 options);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_GetOpenedString(IntPtr device, char[] name, UInt16 options);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_Open(IntPtr device, UInt32 vid, UInt32 pid, UInt16 deviceReleaseNumber);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_Close(IntPtr device);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_SetUartEnable(IntPtr device, bool enable);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_GetUartEnable(IntPtr device, ref bool enable);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_Write(IntPtr device, char[] buffer, UInt32 numBytesToWrite, ref UInt32 numBytesWritten);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_Read(IntPtr device, ref uint buffer, UInt16 numBytesToWrite, ref UInt16 numBytesWritten);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_FlushBuffers(IntPtr device, bool flushTransmit, bool flushRecieve);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_GetUartStatus(IntPtr device, ref uint transmitFifoSize, ref uint recieveFifoSize, ref byte errorStatus, ref byte lineBreakStatus);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_SetUartConfig(IntPtr device, UInt32 baudRate, byte dataBits, byte parity, byte stopBits, byte flowControl);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_GetUartConfig(IntPtr device, ref UInt16 baudRate, ref byte dataBits, ref byte parity, ref byte stopBits, ref byte flowControl);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_SetTimeouts(IntPtr device, UInt16 readTimeOut, UInt16 writeTimeOut);

[DllImport("SLABHIDtoUART.dll")]
public static extern byte HidUart_GetTimeouts(IntPtr device, ref UInt16 readTimeOut, ref UInt16 writeTimeOut);

0 个答案:

没有答案