LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET dll in dependencies

Solved!
Go to solution

I am having trouble getting LabView to use a .NET dll that is listed in a project's dependencies. Here are the details:

 

  • First I copy the LabView project and all files from source control onto a new computer. (Someone else wrote the code, I know it works, and I am a new LabView user. We are using 32-bit LabView 2017 on Windows).
  • I then open the lvproj file in Project Explorer. Under Dependencies, the.NET dll is listed using the correct path to its location. 
  • I start one of the VI's from the lvproj. LabView asks me to find the .NET assembly, and opens up the folder that contains the dll. I can see the dll listed in the folder, but for some reason LabView didn't automatically load it.
  • When I manually select the correct dll, the vi opens with serveral errors, including an Invoke Node: Invalid refnum class error that says the refnum is defined using external files, and one or more of these files is missing.
  • When I open this specific error on the block diagram, I can see it is thrown by an Invoke node that is invoking the dll that I selected.

What should I do so that LabView automatically and correctly uses the dll? 

 

0 Kudos
Message 1 of 10
(4,336 Views)
Solution
Accepted by topic author colorimeter

Sometimes .NET DLLs have dependencies on other .NET DLLs that LabVIEW can't see properly. This can include a type that one DLL uses but another DLL calls.

 

On the original PC, they might have had additional DLLs present that didn't get included in your source, that you're now looking for.  Do you have access to the original PC or any PC where this works?

 

Can you download ILSpy or any other DLL analyzer to check out the DLL you're using, and see if it has dependencies that are missing?

 

Here's an example of what you might see:

Kyle97330_0-1614020693335.png

(This is using one of the DLLs for a motion controller I use).

 

The DLL name is at the top, then under "references" it lists "mscorlib", 4 system DLLs, and 4 Thorlabs DLLs.  "mscorlib" and the system DLLs are included with Windows, but the other 4 are DLLs I have to have in the same folder, but if I open the DLL in LabVIEW and then ask it what its dependencies are, LabVIEW doesn't list them.

Message 2 of 10
(4,324 Views)

1) Unfortunately, the code used to work on the original PC and now it doesn't, with the same errors. I messed something up in 2 days of inexperienced tinkering (here) which resulted in Labview on the original computer seeming to forget how to run the dll. That is why I am trying to install it on a new PC. I figure if I can get it to work there, I will know how to get it working on the original PC, which is the real goal.

 

2) Here are the dependencies of my main DLL from the PE Explorer tool, which I believe are standard and accessible,

colorimeter_0-1614026238531.png

So it doesn't look like my main DLL is calling others. Though there are two DLLs that appear in the same directory as my main DLL.

0 Kudos
Message 3 of 10
(4,295 Views)

OK, now that you posted it, I can see it's MScoreE.dll.

 

Google says that's a "Microsoft .NET Common Language Runtime Execution Engine" DLL, i.e. it's a DLL that is a system component and having a copy of it in your LabVIEW application directory probably isn't the way to go.

 

Are you on Windows 7, 8, or 10?  You might need to install or update your Microsoft .NET framework installation.

0 Kudos
Message 4 of 10
(4,277 Views)

mscoree.dll is the main entry point for CLR - the engine that JITs and executes .NET code. So this is not a surprise since you are using.NET assemblies.

 

For clarity - there is a difference between win32 dll files (;libraries') and .NET dll files ("assemblies"). .NET assemblies can only be loaded using the CLR (as part of the .NET Framework) Yes, its a pity Microsoft chose to use the same file extension.

 

Sounds to me like you are talking about .NET assemblies, in which case PE explorer won't tell you since it will only look for win32 dlls.

 

Look at using ILSpy as suggested to get a list of .NET assemblies being referenced. or check you have a compatible version of .NET Framework installed - you may need 4.x or potentially 3.5 (not normally present in a new Win10 installation).

Message 5 of 10
(4,264 Views)

From ILSpy, here are the references for my main dll, which is indeed a .NET dll,

colorimeter_0-1614087169881.png

There are files called Newtonsoft.Json.dll and SiUSBXp.dll in the same directory as my main dll. They sound kind of generic, and are in the right location for LabView to find and use them, right? 

0 Kudos
Message 6 of 10
(4,242 Views)

@tyk007 - You said to "check you have a compatible version of .NET Framework installed". 

When I checked C:\Windows\Microsoft.NET\Framework as suggested here, it looks like have both 4.x and 3.5 installed,

colorimeter_0-1614088048653.png

Is there anything else I need to check to see if I have the right version for my main .NET dll?

[Also, to answer an earlier question: Both the new computer I am trying to get this running on now, and the original computer that I ultimately want to get it running on, are Windows 10.]

0 Kudos
Message 7 of 10
(4,236 Views)

What version of newtonsoft are your dll using ?

I know this dll has given me some problem in the past.

 

There are some forum posts about how to handle that dll.

0 Kudos
Message 8 of 10
(4,224 Views)

I just renewed my service so I could get tech support on this, and to paraphrase:

The dependencies of the top level .NET DLL, namely the 2 other dlls, were not included in the data folder for the build specifications in the project, so LabView didn't know to use them. The solution was to modify the build specification so they are always included in the data folder.

I hope this helps someone else, and I am very grateful to the suggestions here that got me pointed on the right track. 

0 Kudos
Message 9 of 10
(4,222 Views)

Or else take a look at this post: 

https://forums.ni.com/t5/LabVIEW/LabVIEW-configuration-file-net/m-p/3206680

 

It describes how to setup a config file for use with .net dll's and newtonsoft

Message 10 of 10
(4,214 Views)