Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

DIO SingleRead in C#?

How do you do a DIO.SingleRead in C#? It is a simple matter in VB.NET, but I can't properly initialize the ref Object that gets passed in the SingleRead method.
0 Kudos
Message 1 of 5
(6,827 Views)
What does the code fragment that works in VB.NET look like? Could you please post a sample of the working VB.NET code and the non-working C# code? Thanks.

- Elton
0 Kudos
Message 2 of 5
(6,827 Views)
If the digital IO OCX is called DIO1, the VB.NET code looks like:

Dim myData as Object
DIO1.SingleRead(myData)

in C# it looks *something* like

Object myData = ?????;
DIO1.SingleRead(ref myData)

In C#, an object passed by "ref" needs to be initialized. The question is, what do I replace the "????" with? Or is there another approach?

Just to make things more interesting, I've got NI involved in finding the answer and all I've gotten back so far is the classic tech support reply of "it works when *we* try it".
0 Kudos
Message 3 of 5
(6,827 Views)
Does this work in C#?

object myData = null;
DIO1.SingleRead(ref myData);

Or are you seeing other problems depending on what you initialize the value to?

- Elton
0 Kudos
Message 4 of 5
(6,827 Views)
Anyone have a solution for this yet ?

I tried this and several other variations with no success yet.
0 Kudos
Message 5 of 5
(6,827 Views)