Home > other >  Vb.net call c DLL, abnormal: try to read or write protected memory. This usually indicates other mem
Vb.net call c DLL, abnormal: try to read or write protected memory. This usually indicates other mem

Time:10-03

Vb code:
Public Class Form1
Private Declare Function func Lib "C: \ UniversalViewInterfaceDll DLL" (ByRef res As String) As Long
Private Sub Button1_Click (sender As Object, As EventArgs e) Handles for. Click
Func (res)
Label5. Text=resToVb
End Sub
The End of the Class

C + + code:
Extern "C" {
Int func (char * & amp; S)
{
S="aaaaa";
}
}

Values can come back, but the exception:
Exception: "System. AccessViolationException" (located in mscorlib. DLL)
"System. AccessViolationException" type of untreated abnormalities in mscorlib.
in the DLLOther information: trying to read or write protected memory, this usually indicates other memory has been damaged,
  • Related