Hi all! I have been beating my head against the wall for a couple of days now, and I was hoping that one of the wizards here would be able to help me solve my problem.
I have an unmanaged dll written in C++ that I need to access from VB.NET 2.0.
This is the definition of the function in C++.
In VB.NET I imported this function with the following:
The following is how I am trying to call the imported function. I know that it is incorrect, but at least it's somewhere to start. For simplicity, I'm not doing anything with the output parameters in my example. I'm just trying to get the call to execute at this point.
All three of the parameters are output parameters, and I have no idea how big the resulting arrays are going to be when I call the function. When I execute the code as written, I get the following error:
Please help! I don't know what else to do. Thanks in advance!
-Jim
I have an unmanaged dll written in C++ that I need to access from VB.NET 2.0.
This is the definition of the function in C++.
VB.NET:
extern "C" __declspec(dllimport) int LogGet(int* pLogNumber, char** LogNames, char** LogTimes);
In VB.NET I imported this function with the following:
VB.NET:
<DllImport("CPPDLL.dll")> Public Shared Function _
LogGet(<Out()> ByRef pLogNumber As Integer, _
<Out()> ByVal LogNames() As String, _
<Out()> ByVal LogTimes() As String) As Integer
End Function
The following is how I am trying to call the imported function. I know that it is incorrect, but at least it's somewhere to start. For simplicity, I'm not doing anything with the output parameters in my example. I'm just trying to get the call to execute at this point.
VB.NET:
Public Sub LogGetTest()
Dim LogNumbers As Integer
Dim LogNames() As String = Nothing
Dim LogTimes() As String = Nothing
Dim Success As Integer
Success = CayenComm_LogGet(LogNumbers, LogNames, LogTimes)
End Sub
All three of the parameters are output parameters, and I have no idea how big the resulting arrays are going to be when I call the function. When I execute the code as written, I get the following error:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Please help! I don't know what else to do. Thanks in advance!
-Jim