LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute a C#-form? (.Net-DLL)

Solved!
Go to solution

Hello,

i have a C#-DLL that contains a function which shows a form on execution. On the form there are sveral buttons and the form loops until one of these buttons is pressed. Then the pressed button-nr is returned. This works fine direct in the c#-compiler-testprogram.

But running this in labview makes some problems (as i never called ac#-dll before :-))

What i did yet:

-Connectivity ->,Net -> Constructor Node + Selecting of my DLL

-Then there was a popup to select the function

-Then i selected the "Show"-method

-Added an error-output with breakpoint enabled

 

Now when starting the vi the form is shown.

 

So it seems wo work a little bit. Question is now which method do i have to use the the function is really executed and not only shown (without breakpoint)?

How can i access the return-values of the function?

 

Thanks for help

0 Kudos
Message 1 of 10
(3,797 Views)

You should post some code:

The caller you created in .NET which is working well (pseudo code might be sufficient/better than the complete project)

What you have done so far in LV

 

I would expect the .NET assembly to supply a method like "IsDone" or "FormClosed" which can be polled from LV. Another possibility is that the .NET assembly includes a callback event for the closing of the dialog which you can hook up in LV using the "Register Event Callback" node.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 10
(3,792 Views)

Meanwhile i replaced the Show-method with ShowDialog-method. Now the function is running and no pbreakpoint is needed.

The only question is how to access the returnvalues.

 

The code looks like this:

      public static int Show(int WaitIn,
                                      out int WaitOut,
                                      out int Result,
                                      out string Message)

 

Currently i get only the standard-returnvalue but not the "out"-returnvalues

Hmm, as i write this message i get that i also cannot set the input-parameters...

0 Kudos
Message 3 of 10
(3,787 Views)

Are you now talking about the Show or the ShowDialog method?

 

The returnvalue should be the "result" out parameter. Try to get some information of this.

 

What input parameters are you talking about?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 10
(3,784 Views)

The c#-function "Show" has one input-parameter "WaitIn", one return-parameter and three more result-values which are returned via the out-flag in the function-call.

public static int Show(int WaitIn,
                                      out int WaitOut,
                                      out int Result,
                                      out string Message)

 

In labview i first used the Show-method (same name by chance as my function) which didnt work and now i found the ShowDialog-method that seems to execute the function.

Now i dont know how to access the input-and output parameters mentioned above.

 

Thx

0 Kudos
Message 5 of 10
(3,781 Views)

You still gave no information about your C# testprogram. What function are you using there?

And from your previous two posts, i take it that ShowDialog does not have any parameters. True?

 

If so, search for methods/properties to set/get variable values in the C# assembly during runtime.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 10
(3,778 Views)

The C#-function is only a popup that contains some buttons. The popup is closing as soon as a button is pressed.

The methods "Show" and "ShowDialog" are integrated in labview (see screenshot). They appear when i select the reference of the constructor and select "Create method for ..."

0 Kudos
Message 7 of 10
(3,775 Views)
Solution
Accepted by topic author OnlyOne

Ok, its working now. All the in-and-out-parameters appear in the big list when rightclicking on in the reference and selecting "Create Method".

Solved.

Message 8 of 10
(3,754 Views)

As i understand it, the Invoke node should have the return properties included as outputs. It depends on how the function is setup, compare to e.g. a Internet Explorer-node. I've never done it from A-Z myself though.

edit: Heh, solved it as i answered. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 9 of 10
(3,752 Views)

Thx Yamaeda, only milliseconds too late 🙂

0 Kudos
Message 10 of 10
(3,744 Views)