1

这编译没有错误,但是当我运行这个代码部分时,会出现一些奇怪的错误:

检测到 FatalExecutionEngineError 消息:运行时遇到致命错误。错误地址位于线程 0xd7c 上的 0x792062fb。错误代码为 0xc0000005。此错误可能是 CLR 中的错​​误或用户代码的不安全或不可验证部分中的错误。此错误的常见来源包括 COM 互操作或 PInvoke 的用户封送错误,这可能会损坏堆栈。

我尝试如下:

    Public Enum PipePolicyType
        SHORT_PACKET_TERMINATE = 1
        AUTO_CLEAR_STALL = 2
        PIPE_TRANSFER_TIMEOUT = 3
        IGNORE_SHORT_PACKETS = 4
        ALLOW_PARTIAL_READS = 5
        AUTO_FLUSH = 6
        RAW_IO = 7
        RESET_PIPE_ON_RESUME = 9
    End Enum

...
...

        Dim a As UInt32 = 3000

        SetPolicy(1, PIPE_TRANSFER_TIMEOUT, a)

...
...
Public Sub SetPolicy(ByVal ep As Integer, ByVal PolicyType As PipePolicyType, ByVal PolicyValue As UInt32)


end sub

怎么了 ?

4

2 回答 2

2

好的,我完全在其他地方发现了问题,我不明白。我的枚举完全没有问题,在一些非托管的包装器中出现了一些奇怪的错误:

    Dim PUnmanagedDetailedInterfaceDataStructure As IntPtr = IntPtr.Zero
    PUnmanagedDetailedInterfaceDataStructure = Marshal.AllocHGlobal(StructureSize)

这是我几天前这样缩短的

    Dim PUnmanagedDetailedInterfaceDataStructure As IntPtr = Marshal.AllocHGlobal(StructureSize)

第二次声明有什么问题?!

于 2012-12-28T01:34:25.333 回答
0

您需要使用 PipePolicyType.PIPE_TRANSFER_TIMEOUT 调用它

Public Class Form1
    Public Sub SetPolicy(ByVal ep As Integer, ByVal PolicyType As PipePolicyType, ByVal PolicyValue As UInt32)

    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Dim a As UInt32 = 3000

        SetPolicy(1, PipePolicyType.PIPE_TRANSFER_TIMEOUT, a)
    End Sub
End Class

Public Enum PipePolicyType
    SHORT_PACKET_TERMINATE = 1
    AUTO_CLEAR_STALL = 2
    PIPE_TRANSFER_TIMEOUT = 3
    IGNORE_SHORT_PACKETS = 4
    ALLOW_PARTIAL_READS = 5
    AUTO_FLUSH = 6
    RAW_IO = 7
    RESET_PIPE_ON_RESUME = 9
End Enum
于 2012-12-27T20:10:44.463 回答