The specified record cannot be mapped to a managed value class
Asked Answered
T

1

7

Hi have a vb6 project "PROJVB6" with a class "CLASSVB6" with this content:

...

Public Type ActualParametersType_DOCUMENTI
    Codice As Variant
    Numreg As Variant
End Type
...
Private Gvar_ActualParameters           As ActualParametersType_DOCUMENTI
...
Public Property Let ActualParameters(RHS As ActualParametersType_DOCUMENTI)
    On Error Resume Next

    Gvar_ActualParameters = RHS
End Property
Public Property Get ActualParameters() As ActualParametersType_DOCUMENTI
    On Error Resume Next
    ActualParameters = Gvar_ActualParameters
End Property

I have another c# project that not references the vb6 project but needs use it. I tried with:

var iet = Type.GetTypeFromProgID("PROJVB6.CLASSVB6");
dynamic CalledProgram = Activator.CreateInstance(iet);

And it works. But if i try to get the property ActualParameters with this:

dynamic a = CalledProgram.ActualParameters(); 

i receive this error:

The specified record cannot be mapped to a managed value class.

How can i do to access to ActualParameter for set values of Codice or Numreg without generate the error?

Thanks

Thoroughbred answered 12/10, 2016 at 8:8 Comment(0)
B
2

The problem is ActualParameters is a property and not a Method.

So this would be right:

// dynamic a = CalledProgram.ActualParameters();
//                                           ^^ wrong
dynamic a = CalledProgram.ActualParameters; 
Bridegroom answered 30/9, 2022 at 17:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.