My VB.NET script needs to use a library written in C#, specifically the Connect()
method that has an out
parameter that is a class.
The VB.NET code calling the library method looks like this:
Dim devInfo As DeviceInfoType
myDevice.Connect(ChannelType.DEV_CHANNEL, 0, devInfo)
How the declaration looks like in the C# library:
// `ChannelType` is just an enum.
void Connect(ChannelType channel, UInt16 connectMode, out DeviceInfoType devInfo);
public class DeviceInfoType
{
public GetIdType GetId { get; set; }
}
When I call myDevice.Connect()
the computer waits a few seconds then an error is thrown (so I assume the device is being connected to, and once a connection is made the method tries to assign device info to the out
parameter):
Object not set to instance of object
I can call other methods of myDevice
just fine, so I assume it's something to do with the DeviceInfoType
parameter.
The author of the C# library told me that a C# user would have to call Connect()
like this, but of course there is no out
keywoard in VB.NET:
myDevice.Connect(ChannelType.DEV_CHANNEL, 0x00, out devInfo);
I also tried declaring devInfo
like this, but still get the same error:
Dim devInfo As DeviceInfoType = Nothing
Dim devInfo As New DeviceInfoType