Let me try this a bit different maybe I can get somebody to bite ....:-)
Below Code will work if called direct - but will fail if called with reflection ??
Any Ideas why that would be - again looking at the debugger in the data view, the data looks the "same" regardless on how you call it ..but fails to execute if you use reflection
TEST_COPY is my structure.
What am I Missing ???? It has to be something simple ....
<br />
Public Sub DLL_SUB(ByVal Par As Object)<br />
Dim x As Integer<br />
For x = 0 To NEW_STRUCTURE.Length - 1<br />
' The following code will fail<br />
NEW_STRUCTURE(x) = CType(Par(x), TEST_COPY)<br />
<br />
Next<br />
End Sub<br />
I'm working on Adding DLL's to my main Program and stumbled over the following Issue:
- When trying to copy a structure from the main program to the DLL I'm getting an exception
- I have no problem transferring data to the DLL - it's when I try to copy over the complete structure is when I get the error
- At the point, where the code breaks you can "clearly" see that the correct data is there -it's just the conversion from the object to the structure is failing
Deceleration of Structure
Public Structure TEST_COPY
Public V_STRING As String ' same as KdmCognexSetup(Index)
Public v_Integer As Integer
Public v_Bool As Boolean
End Structure
Dim NEW_STRUCTURE(2) As TEST_COPY
' final code inside DLL that fails (DLL called trough reflection )
Public Sub DLL_SUB(ByVal MethodeName As String, ByVal Par As Object)
Select Case MethodeName
Case "TEST"
Dim x As Integer
'Try
For x = 0 To NEW_STRUCTURE.Length - 1
'**********
' This line fails whil trying to convert the object to the structure [TEST_COPY]
' You can clearly see the data is there - it's just the conversion fails
' What's missing ?
NEW_STRUCTURE(x) = CType(Par(x), TEST_COPY)
'**********
Next
'Catch
'MsgBox("Failed")
'Exit Sub
'End Try
'MsgBox("Worked")
End Select
End Sub
Converting the Structure to an object for and back inside the Main Program is no issue at all = therefore I assume my problem has to do with reflection
I wrote a small test program to trouble shoot the issue - but I'm not sure how I can add the Zip file containing the code to this question
How can I add a file to the question ?
Thanks
Georg