08-14-2014 06:18 AM
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?
08-14-2014 06:54 AM
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
08-14-2014 07:27 AM
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.
08-14-2014 08:36 PM
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.
08-14-2014 11:05 PM
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.