Memory error using Visual C Dll in VB.Net Program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danishce
    New Member
    • Apr 2007
    • 31

    #1

    Memory error using Visual C Dll in VB.Net Program

    I am using Visual C Dll in my vb.net application which pass parameters

    from my application and return value. some times it returns data ok and

    some time it does not return data or return incorrect values.i think

    there is a memory problem so how can i handle memory in my vb.net

    application so it display data correctly. the code for my application

    is:

    <DllImport("D:\ Dot Net NCC\bin\MyDll.d ll", CallingConventi on:=CallingConv ention.StdCall) > _
    Public Shared Function InitPack(ByVal msgtype As Integer, ByVal buffer() As Byte) As Byte
    End Function
    Public Shared Function pckPack(ByVal field() As Byte, ByVal Fieldname() As Byte, ByVal position As Integer) As Byte
    End Function

    //button click event
    Dim m_buffer(1024) As Byte
    InitPack(200, m_buffer) '2+8 = 10

    Dim m_termdata(8) As Byte
    m_termdata = stringcharToByt eArray("TermID6 9")

    Dim bitno41(2) As Byte
    bitno41 = stringcharToByt eArray("9")

    pckPack(bitno41 , m_termdata, 8)


    ---------------------------------------------------------------

    Public Function stringcharToByt eArray(ByVal str As String) As Byte()
    Dim s As Char()
    s = str.ToCharArray
    Dim b(s.Length - 1) As Byte
    Dim i As Integer
    For i = 0 To s.Length - 1
    b(i) = Convert.ToByte( s(i))
    Next
    Return b
    End Function


    please help how can i handle memory in my vb.net application so it display data correctly?
Working...