04-23-2015 06:17 AM
I am trying to use a DLL that I created DLL in labwindow cvi 2010. The DLL should output single. I've attached my source code, header, generated dll, and the LabView code I use. I get Error 1097 "LabVIEW: An exception occurred within the external code called by a Call Library Function Node. The exception may have corrupted LabVIEW's memory.
The DLL is will work properly when passing static values to the structure without error.If we passing dynamically updating structure value to local structure.It gives error code1097.
04-27-2015 09:06 AM - edited 04-27-2015 09:18 AM
I don't really understand what you mean with static values and dynamic in this code. Is the C code you show the one that works or is it the one that crashes? For one, I think it is probably a good idea to change the declaration of the global variable
LVUserEventRef* lvUserEventRef = NULL;
to
LVUserEventRef lvUserEventRef = kNotAMagicCookie;
That way you provide storage for the refnum itself rather than for a reference to the refnum that will be invalidated as soon as your SetUserEventRef() function returns to the LabVIEW diagram.
In addition, I would test in SendEvent() for this variable to be not eaqual to kNotAmagicCookie before trying to even send anything to LabVIEW.