Error: "managed PInvoke signature does not match the unmanaged target signature."
I have this:
When I click "Button1", I get this error:
I read throgh the MSDN that the error box suggests, but I still have no idea how to fix the problem.
Does anyone have any suggestions?
I have this:
Code:
'----Module 1----
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
Function GetStuff(ByVal appname As String, ByVal KEY As String) As String
Dim sFile As String
Dim sDefault As String
Dim lSize As Integer
Dim l As Long
Dim sUser As String
sUser = Space$(128)
lSize = Len(sUser)
sFile = Application.StartupPath & "\Config.ini"
sDefault = ""
l = GetPrivateProfileString(appname, KEY, sDefault, sUser, lSize, sFile)
sUser = Mid(sUser, 1, InStr(sUser, Chr(0)) - 1)
GetStuff = sUser
End Function
Code:
----Form1----
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GetStuff("Configurations", "Test")
End Sub
When I click "Button1", I get this error:
A call to PInvoke function 'MyProgram!WindowsApplication1.Module1::GetPrivateProfileString' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
I read throgh the MSDN that the error box suggests, but I still have no idea how to fix the problem.
Does anyone have any suggestions?