LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.net constructor node error 3

Solved!
Go to solution

.net constructor node return error 3.  The node doesn't take any input, and no output.  Return refnum is invalud, 0.

In both 8.5.1, and 8.6.

 

using System;
using System.Windows;
using System.Windows.Forms;
using System.Drawing;
using System.Collections.Generic;
using System.Text;

 

namespace test
{
    public class Read
    {
        public int Load(String path)
        {
            return 0;
        }

    }

}

 

 

Any idea?

George Zou
0 Kudos
Message 1 of 19
(4,987 Views)
Interesting. The above code does not generate an error in 8.2. I don't have 8.5 or 8.6. What happens if you provide a constructor rather than relying on the default constructor?
Message Edited by smercurio_fc on 09-10-2008 01:47 PM
Message 2 of 19
(4,983 Views)
Interesting indeed.  No error in 8.2, and the refnum is valid.
George Zou
0 Kudos
Message 3 of 19
(4,971 Views)

Create a project in LV and save both the VI and the project. Put the assembly in the same directory.

 

LV changed from 8.2 to 8.5 in how they load assemblies. There should be more info in the help about it if I'm not mistaken.

 

-snow

CTA, CLA, MTFBWY
0 Kudos
Message 4 of 19
(4,948 Views)

snowpunter wrote:

Create a project in LV and save both the VI and the project. Put the assembly in the same directory.


That would have no bearing on this issue.

 

George: It appears that you're using .NET 3.0 given the System.Windows namespace. Perhaps this is a LabVIEW <--> .NET 3.0 issue. When I created the class I was using .NET 2. When I tried to call the constructor using the class compiled under .NET 2.0 with an eval of LabVIEW 8.6 I did not get an error.  

Message 5 of 19
(4,938 Views)

You're right about .net 3.0.  5 stars went your way.

On a .net 2.0, LabVIEW 8.5.1 pc, no error either.

 

So is there a work around?  Or should I uninstall .net 3.0?

George Zou
0 Kudos
Message 6 of 19
(4,934 Views)

So is there a work around? 


 You can try to force LabVIEW to use .NET 2.0 by adding a labview.exe.config file as discussed here. I had to do that with an assembly that would not work under .NET 2.0.

 


Or should I uninstall .net 3.0?


Can't answer this one, since I don't know what you're using .NET 3.0 for, or you may be using it elsewhere. Smiley Wink

 

Message 7 of 19
(4,932 Views)

So is there a work around? 


 You can try to force LabVIEW to use .NET 2.0 by adding a labview.exe.config file as discussed here. I had to do that with an assembly that would not work under .NET 2.0.

 

 

This trick doesn't work for programmer somehow.  LabVIEW automatically picks the latest version when drop the constructor node.

 

And it's very painful to try.  As LabVIEW expects v1.1.4322, or v2.0.50727.

When I typed in v2.0, LabVIEW went crazy!  So I found version 2.0.50727.42 on Microsoft web site.  LabVIEW doesn't recognize v2.0.50727.42 either.

 

 

George Zou
0 Kudos
Message 8 of 19
(4,918 Views)

That's probably because the assembly has been compiled under .NET 3.0. In my case I had an assembly that was compiled under 1.1, but I had both 1.1 and 2.0 on my computer, and I had to make sure that 1.1 was used. I don't have .NET 3.0, so there's no way for me to test this, but the only thing I can suggest is to make sure the assembly is compiled as a .NET 2.0 assembly. This would mean removing those using System.Windows namespaces since they don't exist under .NET 2.0. Unless, of course, you will need them for that assembly.

 

The only other thing I can suggest is what I had suggested before and to provide an explicit constructor, rather than relying on the default constructor.  

Message 9 of 19
(4,907 Views)

As soon as I drop the .net constructor on the diagram, before link to my dll, LabVIEW popup a dialog window, which says:

The version of the assembly you requested was automatically promoted to a later version by the .NET runtime engine.

 

My mistake.  LabVIEW remembers the last assembly I used.

Message Edited by zou on 09-11-2008 12:22 PM
George Zou
0 Kudos
Message 10 of 19
(4,904 Views)