02-22-2021 12:50 PM - edited 02-22-2021 12:57 PM
I am having trouble getting LabView to use a .NET dll that is listed in a project's dependencies. Here are the details:
What should I do so that LabView automatically and correctly uses the dll?
Solved! Go to Solution.
02-22-2021 01:06 PM
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:
(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.
02-22-2021 02:45 PM - edited 02-22-2021 02:51 PM
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,
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.
02-22-2021 06:13 PM
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.
02-22-2021 07:36 PM
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).
02-23-2021 07:34 AM - edited 02-23-2021 07:38 AM
From ILSpy, here are the references for my main dll, which is indeed a .NET dll,
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?
02-23-2021 07:47 AM - edited 02-23-2021 07:53 AM
@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,
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.]
02-23-2021 08:58 AM
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.
02-23-2021 09:18 AM - edited 02-23-2021 09:30 AM
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.
02-23-2021 09:32 AM
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