From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.net Array Input as ref

Hi
i get a .NET DLL and it's my first time to work with it in LV. At first I've a constructor of a class. With an Invoke-Node I call a method of this class. The input to class is an array ( just to pass the value from 0 to 20) in form of ref. I tried to input the array using Net to object vi and To more specific class. I applied the output of To more specific class to ref input. I am still getting am error "1057" at To more specific class vi. Can anyone help me.
Thanks a lot.
Regards.

0 Kudos
Message 1 of 16
(1,403 Views)

Your description makes it sound like you've gotten something backwards... but I guess if you'd chosen the wrong nodes, you wouldn't be able to wire it at all.

Once you have the .NET reference from "To .NET Object", you might be able to pass that reference directly.

If the type won't fit the Invoke Node, then you need a .NET class to cast it to (as you're describing, I think...) but I guess the top input to your More Specific Class node is wrong.

 

Can you post your VI or a snippet?

 

 


GCentral
0 Kudos
Message 2 of 16
(1,353 Views)

Hi

Thanks for replying my message. I tried to input the array as ref input from some previous messages. Please find the enclosed doc having C# code and what I tried.

If there is some example related to issue, please let me know. 

Thanks in advance.

regards.

Gurjit

0 Kudos
Message 3 of 16
(1,341 Views)

Looks like you're passing the type from Get Type to the Open function. You need to pass the array instead.

 

Also, check the numeric representations in LabVIEW - maybe they are perfect but we can't tell from an image.

 

As an aside, what happens when you run that code?


GCentral
0 Kudos
Message 4 of 16
(1,331 Views)

Hi

 

I receive an error 1057. Could you please let me know how to pass the array. I am trying .NET application with labview first time. 

Thanks a lot for your help.

 

Regards.

Gurjit

0 Kudos
Message 5 of 16
(1,314 Views)
@cbutcher wrote:

Looks like you're passing the type from Get Type to the Open function. You need to pass the array instead.

 


Cbutcher already told you!  You're passing the Type in, not the array.  Just get rid of the "object.GetType" node and wire it directly!

Message 6 of 16
(1,301 Views)

Hi Kyle,

 

I tried some ways but didn't work. Could you please let me know, how to connect Array to ref without object.GetType. Please find the enclosed .dll file.

 

Reagrds and Thanks.

0 Kudos
Message 7 of 16
(1,297 Views)

Example_VI.png

Here's my snippet showing my attempt.

 

I created the To More Specific Class constant by right clicking the sfTypes input and then creating a constant, then rewiring it to the top of the To More Specific Class node.

 

You can see here there isn't any problem with the cast - the problem occurs in the library function where an exception is thrown - I expect because it has some dependencies that can't be found from my Downloads folder, or because some other assembly needs to be registered.

The exception message was:

Retrieving the COM class factory for component with CLSID {9F8D4F16-0F61-4A38-98B3-1F6F80F11C87} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).)

 

I didn't close the Array reference here, but you might need to do so - if you do, ensure that the Close Reference happens after anything in your DLL uses it (i.e. put appropriate error wires in to sequence the CR. In your docx file, there was no dataflow dependency that would ensure the Open finished before the Close Ref of the Object/Array.


GCentral
0 Kudos
Message 8 of 16
(1,282 Views)

Hi,

 

It's working fine. Thanks for your help.

Regards.

 

 

 

0 Kudos
Message 9 of 16
(1,268 Views)

Hi Kyle,

 

How I can input command:  string inXml = "<inArgs>" +
"<scannerID>" + scannerId.ToString() + "</scannerID>" +
"</inArgs>";  input for the next command.

Matharoo_0-1617709986525.png

I tried by copy the whole command in string control inXML. I am getting error 1.

Matharoo_1-1617710182545.png

 

Regards .

 

0 Kudos
Message 10 of 16
(1,266 Views)