12-09-2021 12:27 AM
Hi. I am trying to run a LabView VI from C# form application. I followed some steps from a blog to do it but I am getting the error called "The type 'LVBaseRefnum' is defined in assembly that is not referenced". Only difference between my app and the blog is I need to get string value from user. I believe that the error is caused because of the this. I only added "using InteropAssembly" to References section. Screenshot of prototype of source files has been attached and my c# code is follow:
private void button1_Click(object sender, EventArgs e)
{
this.pictureBox1 = null;
this.pictureBox2 = null;
string text = this.textBox1.ToString();
LabVIEWExports.main(text, out Image img1, out Image img2);
this.pictureBox1.Image = img1;
this.pictureBox2.Image = img2;
}
12-09-2021 01:53 AM - edited 12-09-2021 01:54 AM
What sort of LabVIEW object are you passing to the two refnum parameters? If this are not .Net images already you are definitely doing something illegal. LabVIEW refnums are not only meaningless outside of LabVIEW but even outside of the specific LabVIEW runtime kernel instance that created them.
12-09-2021 02:00 AM
I am passing 2 different LabVIEW images. How can I convert them to .Net image object ?
12-09-2021 02:10 AM
By using .Net functions in LabVIEW to copy the contents of a IMAQ Vision image properly into a .Net image object.
And please note that converting images from one environment datatype to another is. one of the more nasty things to do and also in most cases relatively slow since the entire image data needs to be copied. It’s definitely not just the calling of a ready made function. IMAQ Vision knows nothing about .Net Image objects and .Net knows nothing about IMAQ Vision (I believe there used to be a Measurement Studio version of IMAQ Vision but adding that to the LabVIEW/.Net combo only makes things even more complex without solving anything really).
12-09-2021 02:19 AM
Thank you for help but I could not find a built-in function IMAQ Vision image into a .Net image object. I used a function called "To .Net Object.vi", but this is not .Net image object, it is only .Net object.
12-12-2021 04:37 AM
There isn’t a built in function for this. IMAQ Vision is not .Net based so it does not support .Net directly. And such a functions is quite complicated to build even for one pixel format but a general purpose method would need to support all of them.