February 2007

Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28      
Blog powered by Typepad

« Chaos and Order | Main | What is a Service Dog? »

Comments

Sebastian Dau

Hello,

nice documentation!

I asume that most of us already made our own experiences with that sort of LabVIEW - .NET issue.
In other words: I'd have expected to see this great explanation some months(year) earlier.

Is there an understandable reason for the fact that we have to close these unused refnums our own? At first I thougth that these handles are garbage collected when they become invalid (when the function that uses this refnum ends execution) as it happens in other .NET environments.

Thanks, Sebastian

Brian Tyler

First off - I'm glad that this was helpful. If you have other areas that you'd like to see covered, please let me know.

Second, the reason that you need to close the refnums is that LabVIEW is not a garbage collection (GC) system.

To ensure that the .NET object stays around as long as you'll need it, we tell the .NET GC that we're an external reference (via a GCHandle) and thus the object won't be GC'ed until we release that reference.

Again, LabVIEW does track all of these references, but the only time we know it's safe to release them is when all the VI stop executing - and that means long running applications need to be careful.

Hope that helps clear it up.

Sebastian Dau

Thanks,Brian that sounds reasonable to me!

Matt Leonard

I just feel into about every error you listed (except the constructor/close one). I assumed closing any refnum would cause issues with .NET and GC, but the assumption was in the wrong direction.

I wanted to add one additional note for 7.1 users (this is fixed in 8+): If the refnum wired is branched anywhere, and the branch is not closed, the the ref (and hance the GCHandle) sticks around. All branches of refnum wires must be closed. In 8+ it seems that any usage of a closed refnum that was previously branched will through a 1172 exception. This seems to be the correct way to implement this. Unfortunately, my project is stuck on 7.1 and not upgrading. But thanks for this blog entry. Saved me a lot of time.

Matt Leonard

Typo: I meant "fell" into every error.

Brian Tyler

I'm glad the post is coming in handy. I know when I started in LabVIEW near the end of LV 8's development, I was confused myself on the rules and basically discovered the above "facts" by code review and a debugger. :)

I haven't gone back to look at LV 7 code, but I'm surprised to hear what you said about the branching wire. I don't believe that is the case - branching the wire creates a copy of the data on the wire - the refnum itself - but it shouldn't create a new refnum. Do you have a test VI that shows this behavior? If so, please mail it to me.

Shailesh

I am very new in using Labview. I made .Net program and I want to use the methods from DLL generated by .Net framework in labview. I tried to follow the way given on NI website but I am not able to see any method. Can anybody please send me small .Net program which has one public method that I can see and use in labview environment.

Thank you

Brian Tyler

The easiest thing is to try to call something from the .NET framework itself. For example, you can drop down a constructor node and then scroll down to the System assembly. Then select the System.UriBuilder class. This has several nice methods and properties that build up URLs or display their parts. I like it as a beginners point since it's almost all simple strings.

Wiebe

Hi,

In response to a discusion on the NI forum (http://forums.ni.com/ni/board/message?board.id=170&message.id=324051&requireLogin=False ), I just like to let everybody know that everything told here also applies to ActiveX references.

I didn't know that references without a wire don't need to be closed...

Thanks,

Wiebe.

supra tk society

very nice,i like it very much.It is a harvest journey for me when after have a careful look of your blog.Thank you for constantly posting of so many useful tips.They are such a great help to me.Thank you very much!

cheap jordans

It is my great honor to have the chance to look throught the nice and informative posts.Thank you for sharing with us a go!

air jordan

The new post of your blog is defintely stunning!I enjoy your blog quite a lot and at the same time, gain great benificial from that.

air yeezy

It is my great pleasure to hear from you and witness your great masterpiece.All of them look nice! Thank you very much!

coach outlet

Are you felt that it is right? I do not really think that, but can keep personal opinions!

Air Jordan Shoes

They were the best in the world and it was a perfect balance because the core of the team was Italian.

cheap jordans

Don't part with your illusions . When they are gone you may still exist , but you have ceased to live.

louis vuitton outlet

Because of love, moved world, love

retro jordan

frs

air max

My favorite.

true religion

just what i want.

airjordans Shoes

A true friend is happy and pained can share.

jordan shoes

To trust myself, and believe everything nice!

Chanel Replica Watches

And the essence of friendship ethics is trust and respect

Jordans shoes

Or is he cool, calm, and calculating? Does he radiate irrational self-confidence and exude a certainty of excellence that this world has never seen?

new jordans

Persistence makes SUCCESS and self-confidence creates WONDER

The comments to this entry are closed.