【发布时间】:2013-04-15 18:58:51
【问题描述】:
我的问题是,当我运行程序时,它运行良好,但在程序运行一个周期后崩溃。这是一些代码:
Private Sub Receiver(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles COMPort.DataReceived
Dim RXByte As Byte
key = 0
cut = False
c.Open()
Do
RXCnt = 0
Do
RXByte = COMPort.ReadByte
If (RXByte = 29) Then
c.Write(Chr(10))
cut = True
c.Close()
If c.IsOpen = False Then
ts = "BLAH"
Process.Start(System.Windows.Forms.Application.StartupPath & "\e.exe", ts)
Process.Start(System.Windows.Forms.Application.StartupPath & "\Test.exe", c.PortName)
Else
End If
End If
If (cut = True) Then
Exit Do
End If
c.Write(Chr(RXByte))
addText(Chr(RXByte))
RXArray(RXCnt) = LookUpTable(RXByte >> 4)
RXCnt = RXCnt + 1
RXArray(RXCnt) = LookUpTable(RXByte And 15)
RXCnt = RXCnt + 1
RXArray(RXCnt) = " "
RXCnt = RXCnt + 1
SpaceCount = (SpaceCount + 1) And 31
If SpaceCount = 0 Then
RXArray(RXCnt) = Chr(13) ' CR
RXCnt = RXCnt + 1
RXArray(RXCnt) = Chr(10) ' LF
RXCnt = RXCnt + 1
Else
If (SpaceCount And 3) = 0 Then
RXArray(RXCnt) = " "
RXCnt = RXCnt + 1
RXArray(RXCnt) = " "
RXCnt = RXCnt + 1
End If
End If
Loop Until (COMPort.BytesToRead = 0)
Me.Invoke(New MethodInvoker(AddressOf Display))
Loop Until (COMPort.BytesToRead = 0)
c.Close()
End Sub
我认为问题出现在代码的这一点上
Process.Start(System.Windows.Forms.Application.StartupPath & "\Test.exe", c.PortName)
系统抛出 System.UnauthorizedAccessException 错误。此外,测试程序还与同一个串行端口进行通信。当我运行程序时,进程启动并完成,但当前进程抛出错误。是 UAC 错误吗?
【问题讨论】:
标签: vb.net serial-port unauthorizedaccessexcepti