キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

.NET losing referene

Hello,

 

I am currently facing a very strange problem when using the LabVIEW .NET functionality.

 

I am using an external Library from BECKHOFF to interface with their TwinCAT software via ADS (a special protocol). They give out the .dll file for the .NET protocol and I used it in various solutions including MATLAB and VB and it worked seamlessly.

However as soon as I tested the same library with LabVIEW I get connection issues.

 

My first problem was a hidden timeout, which made my reference unusable after 5000 seconds. I "solved" that problem by reconnecting every 20 Minutes. But now a new problem turned up: I don't get any answer from the TwinCAT software after 8-9 hours.

I have to clarify, that I run the same functions from the library in a VB program and LabVIEW to test for a possible solution. However only LabVIEW loses the connection after some time.

ADS Connect.JPG

ADS Read Variable.JPG

 

You can see in the picture above, that the communication inherits a lot of functions from the basic stream class.

 

I don't know if this is a general issue with LabVIEW or if I am missing something in my code.

0 件の賞賛
メッセージ1/8
4,967件の閲覧回数

To be honest what you have posted isn't very helpful in solving the issue. I have applications with .NET assemblies galore running for months straight with no issues. Perhaps you could post your code or an complete example that demonstrates the issue.

 

0 件の賞賛
メッセージ2/8
4,930件の閲覧回数

Hello Engmar,

 

It's very possible that LabVIEW is trying to use a different .NET framework version than you expect. Try to investigate the .NET assembly a little more to see which framework it was targeted for and this should give us some more clues. 

 

If the .NET assembly was targeted for a specific framework, you can use a KnowledgeBase article like this one to make sure LabVIEW is using the right one to load the .NET assembly:

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LDcSAM&l=en-US

 

Also, you should be able to use NI I/O trace to see what calls those methods are actually making. If they match exactly the calls you're making in VB, then it's probably a bitness or framework issue, if not, it's probably an issue with how LabVIEW is reading the assembly. I assume the former.

 

Collin D.
Software Product Manager
0 件の賞賛
メッセージ3/8
4,918件の閲覧回数

Sorry,

 

You'll find a code example in the end. I just copied the relevant code from a rather big project. In order to run the code the TwinCAT Software from Beckhoff is needed.


@tyk007 wrote:

To be honest what you have posted isn't very helpful in solving the issue. I have applications with .NET assemblies galore running for months straight with no issues. Perhaps you could post your code or an complete example that demonstrates the issue.

 


 

I tried to create a config file and am currently testing if it works. It will take several hours for the error to occur anyway, so I'll just have to wait


@TheNIDragon wrote:

If the .NET assembly was targeted for a specific framework, you can use a KnowledgeBase article like this one to make sure LabVIEW is using the right one to load the .NET assembly:

 


 

0 件の賞賛
メッセージ4/8
4,899件の閲覧回数

Did you find the solution? I have the same problem, after some hours, error appears. I think that is a closing references problem. At first, i didnt close the Adsstream and binary reader references and the problem appears after 20 minutes.. not at 5 or 6 hours. I am iterating at 16 ms.

0 件の賞賛
メッセージ5/8
3,818件の閲覧回数

@Juan_Carlos1983 wrote:

Did you find the solution? I have the same problem, after some hours, error appears. I think that is a closing references problem. At first, i didnt close the Adsstream and binary reader references and the problem appears after 20 minutes.. not at 5 or 6 hours. I am iterating at 16 ms.


.NET can only keep 1 million refs open, so if you don't close them when they're not needed that can happen quickly. A quick calculation shows that if you're iterating at 16ms and opens 13 refs that doesn't close you're at 1000000 after 20 mins. 🙂

 

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

Qestit Systems
Certified-LabVIEW-Developer
0 件の賞賛
メッセージ6/8
3,806件の閲覧回数

Yes, I know IT, but i have the same vi showed in a picture before in which i close the reference for the adsstream and for the binary reader and i dont know if i have to close more than this references each time i make a read, because in the examples of beckhoff official site, the references are not closed never. 

0 件の賞賛
メッセージ7/8
3,804件の閲覧回数

Try using the Labview Execution Trace toolkit

It lists all open references which are not closed during runtime. 

0 件の賞賛
メッセージ8/8
3,772件の閲覧回数