Someone from another company who works with ours sent a DLL created in LV, but we couldn't reference it. My next thought was to find a .NET project and DLL that NI had built, to eliminate glitches on the DLL creation side, but those examples are pretty old.
I've done a bit of searching, but can't seem to find *recent* examples of Labview DLLs that have been created for .NET (VB or C#). The ones I can find are:
I've got LV RT 8.5 installed (Windows 7, x64), but can't seem to get those examples to run.
When I try to run these .NET program (with the LV DLL provided), no matter which platform (x86 or x64 or Any), I get an error; either 'BadImageFormatException' (0x8007000B), or 'LoaderLock Detected'.
Any thoughts on this?
Solved! Go to Solution.
If you want a normal dll to get started with API programming try
MessageBoxA from user32.dll
It has an integer, two strings, then another integer. Both integers can be 0, so it should be very easy.
You seem to be confusing .dll and .net a bit. The links you included are tutorials for normal .dll's, not .net assemblies. Do you want to use .net assemblies (also .dll's) or regular .dll's?
Apologies for the confusion-
Ah, I'm programming in VS Community Edition 2013 (have a small VB project, could be C# if needed). Didn't realize a distinction between .NET assemblies (.dlls) and regular .dlls.
We've been able to create a .DLL that some Labview code could use (for another project), and now, we require the opposite be done. Another collaborator is doing their work in Labview, and we need to have functionality that is in their code (this talks to some hardware, for example) be called from a VB or C# program.
So, I've been able to add the 'HelloAssembly.dll' to my VB project, which is a huge improvement. Looking through the Object browser, I see JJBInteropAssembly, and then LabVIEWJJBExports, and under it, New() and HW___32Main. By adding the namespace for JJBInteropAssembly, I can then see it in my code.
Have to install the run time library, and see what happens.
... and, it works!
So, the upshot-
1) Build a simple VB .NET application.
2) Add the DLL above; also, don't forget to all the imported namespace JJBInteropAssembly
3) Install the LVRTEversion2017
You can then add something like button 'btnHello', and use this snippet of code:
Private Sub btnHello_Click(sender As Object, e As EventArgs) Handles btnHello.Click
Dim test As Boolean = False
Dim testout As Boolean = False
Dim sTest As String = "abc"
test = LabVIEWJJBExports.HW___32Main(sTest, testout)
MsgBox("test, testout = " & test & " " & testout)
A popup message box with the Labview icon will show up, with the text 'abc' in the button. The local MsgBox will show test and testout.
From what I understand, what was built was a .NET DLL, not a 'regular' DLL. I'm wondering if you can also create DLLs that can be called by things like Python (a story for another day), but also potentially useful.
And yes that could have a Build Specification for a Shared Library DLL as well as a .NET interop Assembly DLL from the same source
(Could also make it an executable with command line parameters)
as in cmd <MyHW.exe> -"Okey-Dookey"
There are simillar build specs available for those Eunuchs and operating systems that can't figure out if they are Scot or Irish
By the way. I'm curious if my 8-Ball logo showed up nicely during the install?
▼▼▼ that one
The "install" was me putting the HelloAsembly.dll in the correct directory; there was no spinning 8 ball. The zip file wasn't an executable...
Some quick question addendums:
a) If you want to create a void function, is this defined as a subroutine, i.e.:
Declare Auto Sub MyDLLRoutine Lib "..\LabVIEW\MyDLLRoutine.dll" (byval input as single)
instead of a function?
b) How does one handle arrays (input and output)? I see this:
... but this is C#.