错误:尝试读取或写入受保护的内存

时间:2013-03-18 08:43:09

标签: vb.net serial-port dllimport

我有一个winform应用程序试图通过串口发送一些数据。在那里,我使用的是本机DLL,但是我收到了这个错误:

  

尝试读取或写入受保护的内存。这通常表明VB.Net中的其他内存已损坏

这就是我在做的事情:

Public Declare Function AddScreen Lib "BX_IV.DLL" _
    ( _
    ByVal nControltype As Integer, _
    ByVal nScreenNo As Integer, _
    ByVal nWidth As Integer, _
    ByVal nHeight As Integer, _
    ByVal nScreenType As Integer, _
    ByVal nPixelMode As Integer, _
    ByVal nDataDA As Integer, _
    ByVal nDataOE As Integer, _
    ByVal nRowOrder As Integer, _
    ByVal nFreqPar As Integer, _
    ByVal pCom As String, _
    ByVal nBaud As Integer, _
    ByVal pScoketIP As String, _
    ByVal nScoketPort As Integer, _
    ByVal pScreenStatusFile As String _
    ) As Integer

我从带有所有参数的表单加载事件中调用它,如下所示:

AddScreen _
    ( _
    CONTROLLER_TYPE_4T1, _
    SCREEN_NO, _
    SCREEN_WIDTH, _
    SCREEN_HEIGHT, _
    SCREEN_TYPE, _
    1, _
    SCREEN_DATADA, _
    SCREEN_DATAOE, _
    SCREEN_ROWORDER, _
    SCREEN_FREQPAR, _
    SCREEN_COMM, _
    SCREEN_BAUD, _
    SCREEN_SOCKETIP, _
    SCREEN_SOCKETPORT, _
    "C:\\ScreenStatus.ini" _
    )

执行此功能时,我收到了该错误。我该怎么做才能解决这个问题?

0 个答案:

没有答案