From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Leveraging a C# Library

Hello all,

I am having trouble leveraging a .dll library provided by Zebra Techonologies for the DS457 scanner.
I have written a library in C# that is able to leverage the .dll from Zebra properly but for some reason I am struggling in LabVIEW.

 

I have been able to sucessfully call the "open" and "getScanners" methods from the CCoreScannerClass class in LabVIEW but I get a "1316" error when I call the ExecCommand method.
The research I have done is telling me that "1316" is a method not found error, but I am selecting the ExecCommand method from a dropdown, so I don't know why LabVIEW is saying it can't find it.
I think the error may come from the method's request for a "ref string" parameter and an issue with labview passing it a string.

I have attached my work so far in a dropbox because the files are too large.

https://www.dropbox.com/sh/tp42eiu52q4e7si/AACVjUMqizqDdETJKb1aY4X4a?dl=0


The supporting documents folder contains a pdf called "Windows SDK developers guide". I have been using it for information on the Interop.CoreScanner.dll from Zebra.
It also contains the C# code I wrote that properly leverages the Interop.CoreScanner.dll from Zebra.

Zebra Support doesn't know anything about LabVIEW and LabVIEW support doesn't seem to know what the problem is and because it's a 3rd party .dll they won't look into it further. Please Help.

Thanks,
Z

0 Kudos
Message 1 of 7
(4,058 Views)

If you want to attach multiple files, compress the folder that includes all of them and attach the resulting .ZIP file.  Not everyone uses Dropbox ...

 

Bob Schor

0 Kudos
Message 2 of 7
(4,031 Views)

The file is too large to upload as a .zip.

You don't need a dropbox account to download or view the file. You just need to click on the link and select download as a .zip.

0 Kudos
Message 3 of 7
(4,001 Views)

I downloaded your code and ran the main vi.  I got error 1386, which is suggestion that "the specific .NET class is not available in LabVIEW."  Thus, the only thing to do is to create a wrapper for what you need and to call the wrapper.  Here is more information on the issue regarding .NET features not supported in LabVIEW and how to get around it:  http://digital.ni.com/public.nsf/allkb/DC41DCDA972642CF8625787E00732DDD

Clemens | Technical Support Engineer | National Instruments
0 Kudos
Message 4 of 7
(3,954 Views)

Thanks for the reply. 

I looked into building a wrapper but it seems like it requires a header (.h) file. For some reason Zebra has not provided one with the .dll.

0 Kudos
Message 5 of 7
(3,884 Views)

I looked into building a wrapper but it seems like it requires a header (.h) file. For some reason Zebra has not provided one with the .dll.


I believe that C# does not use .h files

You should be able to create a wrapper by just recreating all or just the functions that you need from the .NET assemblly in another c# program and then making that into an assembly, and calling this assembly that you just made in LabVIEW.  If you are using an environment like Visual Studio, the function prototypes should be suggested to you if you reference the dll.  The manual for this dll probably has all the functions that you can call as well.  I haven't looked through the manual, but I would assume it would let you know the names of the things you can call.

There is a tutorial on creating assemblies in c# and using them in LabVIEW

 

I have never tried this before, but it seems like if you need all the functionality of the dll but don't want to write a wrapper function for every function in the assembly, you can try to decompile the .NET assembly (using some software like dotPeek) and then rebuild the assembly/dll making sure that you meet all the requirements stated in the NI article about .NET features

0 Kudos
Message 6 of 7
(3,853 Views)

I had built a c# library that does what you were talking about with acessing the Zebra .dll.

I was hoping there was something I was doing incorrectly in my new labview code that I could fix that would explain why it wasn't working. 

0 Kudos
Message 7 of 7
(3,845 Views)