Home All Groups Group Topic Archive Search About

Crash in VB.net (msconwks.dll library)

Author
14 Apr 2006 12:01 PM
Alessandro Costa
Hi,

I have a problem with an application VB.net,
it export a call-back function with a structure oarameter
that is called in loop from a C language dynamic library.
For 6 time all it's ok, at the seventh time the application CRASH.

What I have seen is that the stack is corrupted from the library
MSCORWKS.DLL.

I have found if there's a fix-pach but I haven't found.

I have declared the struct ic C and in VB as follow :


typedef struct _S_CODELINE_INFO
{
    // Parameter compiled from LS800.dll
    short            Size;                // Size of the struct
    unsigned long        NrDoc;                // Progessive document number
    WCHAR            CodelineRead[CODE_LINE_LENGTH];    // Codeline returned
    short            NrBytes;            // Length of the codeline
    unsigned long        Reserved;            // Reserved for future use

    // Parameter compiled from Application
    short            Sorter;                // Sorter where put the document
    short            FormatString1;            // Set from application NORMAL or BOLD
    WCHAR            StringToPrint1[80];        // String line 1 to print rear of the document
    short            FormatString2;            // Set from application NORMAL or BOLD
    WCHAR            StringToPrint2[80];        // String line 2 to print rear of the document
    short            FormatString3;            // Set from application NORMAL or BOLD
    WCHAR            StringToPrint3[80];        // String line 3 to print rear of the document
    short            FormatString4;            // Set from application NORMAL or BOLD
    WCHAR            StringToPrint4[80];        // String line 4 to print rear of the document
} S_CODELINE_INFO, *LPS_CODELINE_INFO;




<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Public
Class TCODELINE_INFO
        '// Parameter filled by LsApi
        Public Size As Short '// Size of the struct
        '        <MarshalAs(UnmanagedType.I2, SizeConst:=1)> Public Size As
Int16
        Public NrDoc As Long '// Progessive document number
        '        <MarshalAs(UnmanagedType.U4, SizeConst:=1)> Public NrDoc As
Int32
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public
CodelineRead As String = Nothing
        Public NrBytes As Short '// Length of the codeline
        '        <MarshalAs(UnmanagedType.I2, SizeConst:=1)> Public NrBytes
As Int16
        Public Reserved As Long '// Reserved for future use
        '        <MarshalAs(UnmanagedType.U4, SizeConst:=1)> Public Reserved
As Int32
        '// Parameter filled by Application
        Public Sorter As Short '// Sorter where put the document
        '        <MarshalAs(UnmanagedType.I2, SizeConst:=1)> Public Sorter
As Int16
        Public FormatString1 As Short '// Set from application NORMAL or BOLD
        '        <MarshalAs(UnmanagedType.I2, SizeConst:=1)> Public
FormatString1 As Int16 'Byte
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public
StringToPrint1 As String = Nothing
        Public FormatString2 As Short '// Set from application NORMAL or BOLD
        '        <MarshalAs(UnmanagedType.I2, SizeConst:=1)> Public
FormatString2 As Int16 'Byte
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public
StringToPrint2 As String = Nothing
        Public FormatString3 As Short '// Set from application NORMAL or BOLD
        '        <MarshalAs(UnmanagedType.I2, SizeConst:=1)> Public
FormatString3 As Int16 'byte
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public
StringToPrint3 As String = Nothing
        Public FormatString4 As Short '// Set from application NORMAL or BOLD
        '        <MarshalAs(UnmanagedType.I2, SizeConst:=1)> Public
FormatString4 As Int16 'Byte
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public
StringToPrint4 As String = Nothing
    End Class


but don't have found a solution,
can someone help me ?

Thanks
Alessandro

AddThis Social Bookmark Button