06-25-2009 01:23 PM
I have a .NET dll that requires a .NET object be passed to it as a parameter. The object is a struct that contains the following: String, .NET Object, String, String, .NET Object, String, String, String, String. I have put all items into a cluster, converted to a varient, and then wired the varient output to the input of the Convert to .NET Object. However I get an error every time I run my code: LabVIEW: Cannot convert the specified LabVIEW type to .NET object. Method Name: .NET:Convert To .NET Type.
Am I able to convert a cluster to a .NET object to be passed to a .NET dll?
Matt
06-29-2009 09:09 AM
Good Morning Matt,
Try removing the two .NET Objects from your cluster before using the Convert to .NET Object VI to see if the problem you are experiencing is due to trying to convert a .NET Object to a .NET Object.
06-29-2009 09:45 AM
I tried your suggestion of removing the .NET objects in the cluster hower I am still getting the same error message. Here is a screen capture of what I am doing...
11-23-2009 12:50 PM - edited 11-23-2009 12:54 PM
Hi all,
Has anyone solved this issue yet or found an alternative technique?
Matt - did you workaround the error some how?
TIA
-Martin
11-23-2009 01:00 PM
I put a call in to NI and here is what they came up with...Mind you I still haven't been able to sucessfully implement it yet.
The reason for the error is becuase the closest equivalent to a cluster in .NET is a struct. However, it appears that this VI does not convert the cluster into a struct. A possible workaround for this is to create a VI like the one I have attached. Add this VI to a project in LabVIEW 2009, and go to Build Specifications >> .NET interop assembly. This will create an assembly (*.dll) that you should be able to call from LV. Check out LabVIEW Help on .NET interop assemblies, too!
I am still playing with it. I don't know if I am building the DLL wrong or what, but when I call my interop DLL my code hangs and never gets passed the method call to that LV created DLL. If I figure it out I will post how I did it.
As it turns out though, one of the developers here wrote another method that built the .NET object for me. All I needed to do was pass in all the pieces of the Struct. His method then returned a .NET object that I coudl pass around to other .NET assemblies.
11-23-2009 01:03 PM
11-24-2009 04:06 AM
Thank you for your responses, much appreciated. For my application using the approach smercurio suggested works.
05-24-2013 03:20 AM
Hey Martin D
Is it possible for you to send an example vi, I have tried the same method, but LV gives me an Access violation (0xC0000005) error when I passes the struct to a method.
Best regards