DLL Error with VB .NET Program
Ok, so i was looking around on google about how to incorporate DLL's written in C with VB .NET GUI's because its stupidly simple to create one in VB and C is faster. So I want to learn how to mix the two and i found a page of an example thats supposed to do just this (here: http://www.codeproject.com/Purgatory/c_dll_in_vb.asp ). But when I execute the code, I always get this error:
Quote:
An unhandled exception of type 'System.EntryPointNotFoundException' occurred in Call_C_dll.exe
Additional information: Unable to find an entry point named ReturnInParam in DLL vcdll.dll.
VB Code:
Code:
Public Class Form1
Inherits System.Windows.Forms.Form
_
| Windows Form Designer Generated Code |
-
<DllImport("vcdll.dll", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Sub ReturnInParam(ByRef Stan As Integer, _
ByRef Message As String)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Num As Integer = 8
Dim Message As String = "Hey"
ReturnInParam(Num, Message)
MessageBox.Show(Message)
End Sub
End Class
C Code:
Code:
#include <WINDOWS.H>
LPCSTR DisplayStringByVal(LPCSTR pszString)
{
return "How's it goin? ";
}
void ReturnInParam(int* pnStan, char** pMsg)
{
long *buffer;
char text[7] = "Hallo ";
char name[sizeof(*pMsg)];
strcpy(name, *pMsg);
*pnStan = *pnStan + 5;
buffer = (long *)calloc(sizeof(text)+sizeof(*pMsg), sizeof( char ) );
*pMsg = (char *)buffer;
// do not free the buffer, because it will be used by the caller
// free( buffer );
strcpy(*pMsg, text);
strcat(*pMsg, name);
}
the name and path of the dll is correct :( so whats wrong? thanks