LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the labwindows/cvi equivalent to the .net constructor node in labview?

I'm trying to use a .net assembly in labwindows/cvi v8.  I've tried using the .net controller to create wrapper functions however I get error -6571 (target invoked by cvi .net library thew an exception) when calling the create function.
 
I've been able to use this .net assembly in labview 8 with the .net constructor node and then the invoke node to access the methods I need. 
 
Is there a specific set of functions I can use in labwindows/cvi which can operate just like these labview vi's? 
 
Examples would be great as I've looked at some of the .net functions in cvi and am unsure how I would use them, even after viewing all the help on this topic.
 
Thanks! 
 
Brian
0 Kudos
Message 1 of 20
(5,464 Views)

Calling the CVI .NET Library functions directly is not recommended as it is quite difficult. This is why CVI creates a wrapper for the .NET assembly - basically, the wrapper uses the .NET library functions to interact with the assembly. Some simple CVI .NET examples are installed in the samples\dotnet folder under CVI.

The particular error you are getting indicates that the target object in the .NET object was called but it threw an exception - this is most probably due to passing some invalid parameter. If the assembly you are calling is a commonly available assembly, you can post the code snippet that is returning the error and others on the forum could try checking it.

0 Kudos
Message 2 of 20
(5,444 Views)

Thanks for you response.  I'm actually trying to follow the example getinfobyzip since that seems to be exactly what I want to do.

I'm getting that error when calling the very first create function which seems more like a cvi generated function for any assembly rather than a method for the object.  (Although maybe it has somethign to do with the constructor for the object in the assembly?)

I assume this is the proper example to follow.

In labview it seems very straight forward:

I use the constructor node to identify the object in the assembly I want.

Then use the invoke node to call the methods. 

 

Its a 3rd party .dll for their spectrometer.  They mentioned to me that they moved from .net1.1 to .net2.0 and in doing so labview 7 was no long compatible.  I dont' know if that has anything to do with me but it seemed that cvi might possibly be a release behind labview in terms of .net tools.

I'm not really sure how to proceed.

Everytime I talk with the company they want me to create an activexserver to interface with a com object they say is installed.  This seems very different than what labview or labwindows would be doing. 

Brian

Message Edited by hillb on 01-26-2007 02:28 PM

0 Kudos
Message 3 of 20
(5,431 Views)
Hi Brian,

I don't get that error with the GetInfoByZip example.  Do you get any errors with any of the other .NET examples?

Here is a good intro to .NET libraries in CVI, posted by Jonathan:

How do i use a c# dll in labwindows
http://forums.ni.com/ni/board/message?board.id=180&message.id=27163

and another one:

Can we load/import external DLL created by VB.net?
http://forums.ni.com/ni/board/message?board.id=180&message.id=27289


There is also a very good overview of the .NET library in CVI help, if you Index for ".net" and choose the ".NET Library" topic.

CVI 8 and .NET 2.0 are compatible.


Gavin Fox
Systems Software
National Instruments
0 Kudos
Message 4 of 20
(5,391 Views)
The GetInfoByZip example IS working for me.
 
However, when I try to do the same thing with this 3rd party dll, an exception is thrown during the create method.
 
Is there nothing I can do in this case?
 
Should this method be analogous to the constructor node in labview that is working for me?
 
I've tried to read all the documentation on this but I can't figure out if the problem is on my end or with the assembly.
 
Brian
0 Kudos
Message 5 of 20
(5,385 Views)
Hi Brian,

Have you run through the "Create .NET Controller" Wizard steps without any problems there to create a new wrapper?

Do you get this error with your DLL when you just run the Initialize method (loads your assembly)?

Do you get this error if you use the general .NET (not the GetInfoByZip wrapper) Create method?



Gavin Fox
Systems Software
National Instruments
0 Kudos
Message 6 of 20
(5,379 Views)

Hi Gavin,

I get through the "create .net controller" wizard without any problems.

I get a 0 back from the initialize method. I was confused by this though because i don't remember seeing it in the getinfobyzip.

I'll have to try the other create method, although I guess I'm having problems just loading the assembly?

Brian

0 Kudos
Message 7 of 20
(5,373 Views)
Hi Brian,

The 0 returned is ok.
There was an issue in CVI 8 with this that was fixed in 8.1.
Here is a link to the evaluation version of CVI 8.1, so you can try it there.

https://sine.ni.com/apps/utf8/nigb.guestbook?code=GB_EVALCVI&lang=US&gb_prof_id=1323&scode=&pr=1323&shadow_flag=N
Gavin Fox
Systems Software
National Instruments
0 Kudos
Message 8 of 20
(5,368 Views)

Hi Gavin,

I was able to test everything out in 8.1 today.  One thing odd was that I wasn't able to create the .net controller from the same assembly, I was getting an error for some reason.  I was able to use a newer version of the assembly however to create the wrapper code and instrument driver. 

During the init call I now get an error however, code -6579 which I believe just means it could not load assembly.

Do you know reason I would be getting this error?

Thanks very much for your help, I am very grateful.

Brian

0 Kudos
Message 9 of 20
(5,335 Views)
Hello

Could you post the assembly installer here? It would help us get to the bottom of things faster if we can reproduce the error in-house.

Thanks
Bilal Durrani
NI
0 Kudos
Message 10 of 20
(5,319 Views)