05-08-2015 03:05 AM
Hi Community
I want use the .NET features of Labview to build a very simple application by using the .NET API of an instrument manufacturer.
Up to now we have some experience in using .NET in labview. (Sometimes good and sometimes bad expirience)
Now I have the big problem to "translate" this line into labview code.
var remoteService = driver.Services.GetService<IRemoteService>();
////Get the Service of type <T>
///var aService = driver.Services.GetService<T>();
///C#:
//Get the IRemoteService instance
///var remoteService = driver.Services.GetService<IRemoteService>();///
Is there anyone out there who has a good idea to solve this problem.
A solution without building a wrapper would be prefered but may be impossible.
Thank you and have a nice weeked
Gernot
05-08-2015 03:58 AM - edited 05-08-2015 03:58 AM
The only way to avoid a wrapper DLL is to use .Net Reflection. That is however a painful process since you have to generate the objects yourself through low level .Net functions. Here is an example for the creation of generic .Net lists. However I personally wouldn't consider this preferable above the creation of a .Net wrapper, and it certainly has a great potential to fail if you upgrade some .Net componenents related to your object.
05-10-2015 05:53 PM
rolfk, what I can't follow is how to create the .NET constant which is wired into the target class of "To More Specific Class"?
05-11-2015 03:20 AM - edited 05-11-2015 03:35 AM
Well, usually you would have some API that requires this specific type so you can normally do a right-click "Create Constant" from there. If you don't have that you could also use the generic System.Collections.IList interface, but you will have to convert the according datatype yourself to and from a .Net refnum (To .Net Object.vi and .Net Object to Variant.vi).
05-11-2015 05:33 PM
Right, I get doing it that way, although it gets very cumbersome. So what you're saying is that to get the constant (at the top of this image):
you need to write a Wrapper to define it - in which case you can get by without using the .NET Reflection methods anyway. I was thinking there might be a scripting method that would create a .NET constant of a particular class.
05-12-2015 12:42 AM
Hi all
Thank you for your help.
I tried it doing without a wrapper without sucess (after a few hours)
So now I went for the c# wrapper dll which seems to work very nice.
I think a scripting vi is no option because I need to build a stand alone application where it was said this may not work in builds. (don't know if this is true)
Neverthelss
Thank you
Nottilie