From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Translate C# to LabVIEW .net Code

I have an issue where I can’t initialize Gmap.net dll assembly. These is an example on the website  here how to initialize but it is written in C#. Can someone please help me write this code in LabVIEW.

 

Code and dlls attached.

Download All
0 Kudos
Message 1 of 7
(4,076 Views)

Hello Nermin, 

 

To call from a .NET assembly in LabVIEW, you will use Constructor, Invoke and Property Nodes. Constructor Nodes create objects, Invoke Nodes act as methods, and Property Nodes declare properties of the object. There is a short description of calling a .NET assembly at the bottom of this KnowledgeBase article: 

 

How Do I Call a Dynamically Linked Library (DLL) from LabVIEW? 

http://ae.natinst.com/public.nsf/webPreview/DCB90714981A1F148625731E00797C33?OpenDocument

 

Additionally, there is a community example that demonstrates how to call .NET assemblies in LabVIEW. 

 

Calling .NET Assemblies in LabVIEW

https://decibel.ni.com/content/docs/DOC-5921

Cameron Schaefer

Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(4,001 Views)

I have used .net assembly before. It just that this particular one gives me trouble. I have tried using constructor nodes to initiate controls, but it always gives me 1772 error. 

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

@Nermin wrote:

I have used .net assembly before. It just that this particular one gives me trouble. I have tried using constructor nodes to initiate controls, but it always gives me 1772 error. 


The constructor node is similar to the .Net new operator. If a .Net class is however a static class you do not instantiate it in .Net with the new operator but simply use it.

So maybe your classes you try to use are really static classes. In that case you simply create a .Net refnum control, assign it the class it should have, et voila, you can use it.

 

Another reason you might get trouble when trying to use .Net classes in LabVIEW is if the class uses generics. LabVIEW does not support use of classes that use generics in their class type declaration.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 7
(3,938 Views)

Rolf,

 

I was not sure how to try you suggestion since I am fraily new to .net.  I have attached the error that I get everytime I try to run. Can you help expain how abstract class works in labview.

 

Nermin

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

Rolf,

 

I was not sure how to try you suggestion since I am fraily new to .net.  I have attached the error that I get everytime I try to run. Can you help expain how abstract class works in labview.

 

Nermin

Download All
0 Kudos
Message 6 of 7
(3,858 Views)

Well you should learn a little about OOP in general and .Net specifically. Abstract classes can NOT be instantiated. There must be some real class that derives from the abstract class and implements all the abstract methods the abstract class defines to need to be implemented.

 

So the situation with your API is either of two situations.

1) Your API provides other classes that derive from the abstract class and you should instantiate them.

2) Your API provides abstract classes that it expects a user to derive from and pass the full class back into some API methods as parameter, such as a callback (event) implementation. Abstract classes are in that respect very much like interfaces. You simply can't instantiate them directly.

 

In combination with LabVIEW you can solve 1) bij identifying the real class and using that.

2) can't be solved with LabVIEW only. You would have to create a .Net assembly in VB .Net, C# or C++ that provides the full class that derives from the abstract class and instantiate that from within LabVIEW.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(3,779 Views)