Jump to content

Labview Freeze/Crash using C# .NET dll


Recommended Posts

Hello there,

I have a big problem here.  I want to use a bunch of dll created in C#.  The dll are used to initialize and read a temperature sensor device.  I only have to do the initialization and close my vi to freeze it.  Do you know what could cause this?  The problem is occurring when I want to stop or close the vi.

Any help would be welcome.

Thank you,

Link to comment

Calling Dlls from Labview is a bit of a black art. The most likely cause of the crash is sending the dll a parameter that's different than what it expects. For example, if the dll is expecting a 16 bit integer and you send it a 32 bit integer, Labview probably going to crash. Sounds like that's what's happening to you.

Did you write the dll or do you have access to the source code and/or *.h file? If so, double check that you are calling the dlls with the correct parameters. Sometimes in dlls you'll run across complex data stuctures that don't match very well with Labview data types. It that case you usually need to write a wrapper dll that translates the data types into what the dlls expect.

Check out this article, it's a starting point for how to call dlls from Labview. It also discusses the difference between calling a regular dll and a .NET assembly.

http://digital.ni.com/public.nsf/allkb/DCB90714981A1F148625731E00797C33?OpenDocument

Link to comment

Calling Dlls from Labview is a bit of a black art.  The most likely cause of the crash is sending the dll a parameter that's different than what it expects.  For example, if the dll is expecting a 16 bit integer and you send it a 32 bit integer, Labview probably going to crash.  Sounds like that's what's happening to you.

Did you write the dll or do you have access to the source code and/or *.h file?  If so, double check that you are calling the dlls with the correct parameters.  Sometimes in dlls you'll run across complex data stuctures that don't match very well with Labview data types.  It that case you usually need to write a wrapper dll that translates the data types into what the dlls expect.

Check out this article, it's a starting point for how to call dlls from Labview.  It also discusses the difference between calling a regular dll and a .NET assembly.

http://digital.ni.co...33?OpenDocument

Thanks for the hint, but I've check and I mostly call functions from the dll without passing parameters.  The problem is that labview can crash only by closing a probe, or with a breakpoint.  It's like if the Dll is catching every labview events but don't know how to deal with them even if it's destined to it.

Does this talk to you?

Thank you,

Link to comment

Sounds like your .Net assemblies are somehow messing badly with some system internals. I know this behaviour form standard DLLs who try to hook themselves into system calls to do some black magic. When trying to unload those DLLs with the FreeLibrary() function, Windows gets confused in some sort of deadlock situation.

Seems Microsoft specifically discourages explicit unloading of DLLs on application termination, saying that this can cause dead lock situations for many API calls during such an unload call. Not sure if this applies in your case but the way you describe it it sounds somehow similar. Problem here is that you can not tell LabVIEW not to attempt to unload a .Net assembly when it wants to close down the VI that contains the last .Net Node to that assembly.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.