LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recent xamples for creating DLL for VS .NET Community edition 2013 (VB or C#)

Solved!
Go to solution

Hi all-

 

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:

 

 https://forums.ni.com/t5/LabVIEW/Calling-Labview-DLL-from-a-C-app/m-p/116632?requireLogin=False

 

http://www.ni.com/example/31050/en/

 

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?

 

Thanks.

0 Kudos
Message 1 of 10
(2,692 Views)

Well, Let's try this (Attached)

 

A Hello World'Capture.pngBuilt as a .NET with Installer

Source and builds attached

The installer does not contain the LVRTEversion2017 available here

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 10
(2,660 Views)

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?

0 Kudos
Message 3 of 10
(2,652 Views)

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.

 

 

 

 

 

0 Kudos
Message 4 of 10
(2,644 Views)
Solution
Accepted by topic author apacc

... 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)

    End Sub

 

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.

 

Message 5 of 10
(2,636 Views)

Outstanding!

 

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


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 10
(2,625 Views)

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...

 

0 Kudos
Message 7 of 10
(2,585 Views)

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:

https://forums.ni.com/t5/LabVIEW/LabView-Net-Interop-and-Arrays/td-p/3183711

... but this is C#.

0 Kudos
Message 8 of 10
(2,569 Views)

Here we are talking about dll file, in your problem statement for creating dll for vs.net community. You need to download this missing .https:fixdll.net/activation.dll  file, to fix this issue. Running this file after that your problem would be fixed.

0 Kudos
Message 9 of 10
(2,094 Views)

In my previous comment url is incorrect. So new url is https://fixdll.net/d3d9

0 Kudos
Message 10 of 10
(2,074 Views)