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 WPF and Labview are boggling my brain


@mattcarson wrote:

Hi again, thanks for your help!

I do not know C# well enough to understand why dependency on a module could be a joke.  How did you discover that? I'd like to follow up on my own.

 


The DLL you posted, "RapidCode.NET.dll" is looking for another file called "RapidCode" or "RapidCode.dll".  Which probably means that there's an older, non-.NET DLL that "RapidCode.NET.dll" is looking for.  So it's a little bit funny that your DLL has a dependency on it that looks almost like it depends on itself.

 

Anyway, to actually contribute, another program you can try to look for dependencies with is ILSpy:

https://github.com/icsharpcode/ILSpy/releases

 


@mattcarson wrote:

Without a constructor to make an object, what reference do I feed to the invoke and property nodes?

 


To answer this, which seems to have been somewhat skipped over, some properties and methods in .NET are what is known as "Static", meaning they are members of a class but using them is done without needing a reference to a specific instance of the class.  Sometimes, you will need to use static methods or properties (via property or invoke nodes) instead of constructor nodes.

 

To do this:

1. Put down an invoke node.  (Property nodes work the same way, but they aren't what you're looking for to get started...)

2. Right-click it, and go down to the "Select class ►" option, then choose ".NET ►", then choose "Browse...".

3. A window will come up very similar to the one you use when selecting a Constructor. 

4. If the .NET DLL you want is already in memory you can find it using the dropdown.  If not, click "Browse..." and choose your DLL on disk.

5. Now, look through the listings there and find your class in the DLL you're interested in:

 

Select NET node.png

6. Click on the node and look at the list of methods.  Anything starting with "[S]" is a static method.

Select static method.png

The example you showed had one argument in it, so the checked one there is what you probably want if you want to specify a path, or choose the one with nothing above it for the default option (which is actually what the example does, because the /* */ symbols in it mean the argument is commented out).

 

And now you have a working .NET invoke node with no reference passed in!

Working NET node.png

Message 21 of 32
(1,012 Views)

Thanks Kyle for your details. Those functions I can see are exactly what I was expecting to find. I am (barely) familiar with static objects that act as an instance, and good to know what all of those [S]'s are for!

 

Unfortunately I now get 'can't load assembly errors' when I try to use the assembly browser, after uninstalling and reinstalling both 32-bit and 64-bit versions of various versions of Labview proper and NXG, plus shifting to a different 64-bit package (at the advice of the dll developer).  I've spent DAYS trying to fix this 😕

0 Kudos
Message 22 of 32
(985 Views)

Unfortunately I now get 'can't load assembly errors' when I try to use the assembly browser

 

I got the same error.

I think It's because RapidCode.dll is missing.

 

George Zou
0 Kudos
Message 23 of 32
(971 Views)

If I only use the 32-bit version of their, their assembly comes through with all I want.

NOW...some of the methods bomb.  I can do simple things like read version or the state of the motion controller but major commands I get an error saying the dll threw an exception, which leaves me back to a lot of guesswork.

0 Kudos
Message 24 of 32
(964 Views)

Maybe...

 

If you download dlls, WIndows blocks them by default. LabVIEW won't be able to load them.

 

In file explorer, right click the file, select properties, and tag the unblock (or was is unlock?) option.

 

You should do this for all dlls (e.g. also dependencies). This applies to 32 bit and 64 bit dlls...

 

EDIT: I'd still check, although this will only give you the troubles you describe if the advanced functions are dynamically loaded by the main dll, when you try an advanced method.

0 Kudos
Message 25 of 32
(947 Views)

@larry_koler wrote:

If I only use the 32-bit version of their, their assembly comes through with all I want.

NOW...some of the methods bomb.  I can do simple things like read version or the state of the motion controller but major commands I get an error saying the dll threw an exception, which leaves me back to a lot of guesswork.


Can you post the text of the 1172 error that the exception generated?  It may give a hint as to what the issue is.

0 Kudos
Message 26 of 32
(930 Views)

Hey All, thanks for the help.

I should update my information. There are two packages from the DLL provider and I currently have the later version installed.  Both have 32 and 64-bit versions.

I can view both of the bit versions of the dll in the assembly browser for the earlier package. The later package gives me an error and does not show any members, in either bit version.  The vendor says the later version actually has fewer dependencies (they were rolled up into the DLL)

 

I looked through all of the DLLs and none of them have any text referring to anything being blocked.

 

In the 64-bit Labview when I can see all of the members, I can run 'CreateFromSoftware' without any errors and some basic commands to look at things.  When I try to run a method called NetworkStateGet() (prior to attempting to start a network), I get this over-flow error, which sounds suspiciously like a data-type error (or clash between to bit-ness versions?_

 

Invoke Node Error calling method RSI.RapidCode.dotNET.MotionController.NetworkStateGet, (System.OverflowException: Arithmetic operation resulted in an overflow.) <append><b>System.OverflowException</b> in Untitled 1

 

When I run the 32-bit version of the same (32 bit dll and 32 bit Labview), I get this error:

Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: RSI.RapidCode.dotNET.RsiError: Win32 RMP: device error :: {platform.c, line 5362} (Error 5124) (MotionController::MemoryGet) (Object 0) (File motioncontroller.cpp) (Line 1147) (Version 10.1.2.0) <append><b>RSI.RapidCode.dotNET.RsiError</b> in Untitled 1Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: RSI.RapidCode.dotNET.RsiError: Win32 RMP: device error :: {platform.c, line 5362} (Error 5124) (MotionController::MemoryGet) (Object 0) (File motioncontroller.cpp) (Line 1147) (Version 10.1.2.0) <append><b>RSI.RapidCode.dotNET.RsiError</b> in Untitled 1

0 Kudos
Message 27 of 32
(918 Views)

@larry_koler wrote:

When I try to run a method called NetworkStateGet() (prior to attempting to start a network), I get this over-flow error, 


This is a stab in the dark here, but often in C coding some actions are expected to cause an exception if they have a problem.  It could be that running something to get the state of a network that hasn't started is supposed to cause an exception.  There's a thing called a "Try-Catch" block that is their version of error handling, and LabVIEW doesn't really work that way, and the best it can do is flatten the exception to a string, and stick it on the error wire.

 

Do you think you could try starting a network and then run NetworkStateGet() and see if it works?  I can understand it always feels "safer" to run functions that just gather information (as opposed to ones that actually do something), but it may be backfiring here.

 

The only other thing I can think to check is to look in all your documentation and see if the device has any reference to "Error 5124", which is mentioned in the exception, or to check with the manufacturer and see if they have more in-depth example code you could try to copy.

Message 28 of 32
(914 Views)

The example code from them uses the NetworkStateGet() prior to starting the network so shouldn't be a problem there.

I am conversing with the dll provider about those error messages.

0 Kudos
Message 29 of 32
(884 Views)

In the meanwhile I tossed some kudo's at Kyle (hint 😊). Those are some lengthy insights that took real effort.

0 Kudos
Message 30 of 32
(868 Views)