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: 

Does not work if I copy the block diagram to a new VI

I was trying to search for a volume label string in my hard drive, and I want the VI to report in which drive this volume label is.

I chanced upon this solution.

But when I created a new VI, and copy everything in the block diagram of the original VI and paste them to my new VI, and run it, it does not work. The error is as below:

 

Any help?

Doesnt_work_if_I_copy_block_diagram.jpg

 

error.JPG

0 Kudos
Message 1 of 5
(2,593 Views)

Notice the Method called GetDrives on the .NET object "DriveInfo".  In this tiny piece of (isolated) code, there is no .NET object unless you created it (and created the right one).  I'm not a .NET expert, but when I did try to "look underneath the Microsoft covers", what I found there was much too complicated to waste much time.

 

If you are an accomplished LabVIEW programmer (which, from this question, I'm guessing you are not) and have experience with understanding .NET technology, then you should be able to figure out how to create a .NET object, get the right one, then continue with this exercise.  If this is not the case, then you are possibly "in over your head" and should consider some other solution to your question.

 

BS

0 Kudos
Message 2 of 5
(2,578 Views)

I just copied the VI found here.  Did a copy and paste of the code in a new VI and it still worked for me.

 

You may want to make sure the initial property node is pointing to your latest version of the System IO DriveInfo.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 5
(2,567 Views)

Hi crossrulz,

I don't understand the solution you proposed. I couldn't find the "initial property" node..

I thought copying the code in the block diagram should copy everything including the properties..

Please advise.

0 Kudos
Message 4 of 5
(2,519 Views)

In order to properly access a dotNET assembly in LV, as in other languages, you must first instantiate a constructor for the object you desire to access. This is what crossrulz meant.

 

You will find a generic constructor on the dotNET palette. By default when you drop it down you get a browser to search for the object you desire to create. The output of the constructor is a reference that is needed by the following code.

 

Mike...

 

Always be careful about closing dotNET references, even for simple, quick examples. In addition to memory problems, open references sometimes cause program instabilities.


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 5
(2,478 Views)