09-04-2020 07:35 AM
when labview got event from a C# DLL, how can i check the event data? I try the official example, the panel operated well, but the event data keep zero value.
Solved! Go to Solution.
09-04-2020 11:25 AM - edited 09-04-2020 11:30 AM
Open the Callback subVI. The data is inside it when it's called.
09-06-2020 02:38 AM
I am a new learner of labview, The official site example I used determined that the event data could not be displayed。 Today, I try use another method to study the issue, And got the same result, i feel A little helpless.
I guess the official example may not use any C# Dll "event data" , It just responce the fitted "event action" only, So i make another C# DLL which has eventArgs which defined by myself 。
the step is:
1. I write a samp C# dll, which input a int32 number, example as 100, if method called, it will fire a event with eventArgs data as number 105 (just simply added by 5).that is all. I test it in c# work correctly.
2. then i write a labview vi to use the C# dll, and try my best to catch the event data(expected 105, if i input 100 before call DLL), But the callback event vi seems not been callbacked,
3. labview 2020 study version is just 32bit(the official web suggest me try use 32bit), use NET4.0 CLR, and visual studio 2019 also use Net4.0, but 64bit
4. I attatched all the document below, anybody can give me some suggestion? guohuimao@163.com thanks a lot.
09-06-2020 08:36 PM
You have two problems, based on a mis-understanding of how LabVIEW executes code:
Attached is a modified example that adds a control reference to the user parameter when the callback is registered. The callback can access this reference in order to write data to it. Your main VI execution settings have also been changed to run in the single user interface thread so that no multi-threading occurs.
When I run this example, the control value "before call DLL" matches the control that whose reference was passed to the callback "From event". I see from your C# code that you aren't doing any "+5" addition to the number provided to the args class so we should expect these two controls to be the same value.
09-07-2020 07:23 AM
Dear expert:
Thanks a lot, I now understand some of what you said. But i down and try run the new project which corrected by you, It seems can not load my C# dll now.
I recompiled the C# project , and replace into the labview diagram again, still can not load it...
Maybe It caused by the diffrence of our visual studio ?
Yours
09-07-2020 04:39 PM
I didn't modify your assembly or C# source code files / solution. I did update your main VI and add a replacement callback.
Try editing the .NET node in your block diagram and re-selecting class and member.