LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error 1004 when calling VI from executable

Solved!
Go to solution
I'm trying to implement the tutorial "creating a windows NT service using LabVIEW", but I have had no success. When I run my client VI I've get the error 1004: The VI is not in memory. I'm still working with the regular executable, not the service yet. I will cross that bridge later.  I made sure that the data generator VI was included in the executable (See the attached files - no cookie generator VI, just a random number generator), and I configured the VI server in the project explorer.  If I run the service VI in LabVIEW (not the executable) and modify the client VI to look in the memory instead of communicating via ports, then everything works seamlessly, so I think the problem is related with some configuration of the executable.  Any help will be appreciated.

 

0 Kudos
Message 1 of 11
(6,721 Views)
Your files are not attached.
0 Kudos
Message 2 of 11
(6,720 Views)
Oops! Forgot the attachment. Files are attached now..
0 Kudos
Message 3 of 11
(6,712 Views)
 

Hi jrods,

I have been messing with it for a good bit and can’t seem to get it to work either.  I think the problem may lie in the way the client is referencing the VI verse how it is referencing the .exe.

Adam H
National Instruments
Applications Engineer
0 Kudos
Message 4 of 11
(6,679 Views)
Solution
Accepted by topic author jrods

There's several points here:

1) change the boolean constant in svcSrvr.vi to a control, else the VI doesn't seem to be included in the exe (even though it's specified in the build specification) [this looks like a bug to me]

2) in the application, use a different port (else the project is still listening on that port and the application can't listen on the same port), i.e. change the port number in the application.ini. Alternative: close the project before running the exe.

3) wire "localhost" (or the machine name) to the machine name input of open application reference.

 

Hope this helps,

Daniel

Message 5 of 11
(6,669 Views)
Hi jrods,

Did you add the line runAsService=TRUE to the .ini file like this DevZone says you need to.  It looks like in the code you attached you had not added it.  This could be part of the problem if this is the exact code you are trying to get working.

Adam H
National Instruments
Applications Engineer
0 Kudos
Message 6 of 11
(6,649 Views)

I finally had chance to put my hands into this again. Thanks dan_u as with your advice the application is working now. "localhost" must be wired to the machine name. To keep the locators VI in memory a control must be used instead of the constant that the tutorial suggests. It would be good if NI updates the tutorial.

 

Thanks again to all the people who took the time to shed some light into this.

0 Kudos
Message 7 of 11
(6,620 Views)

Hi All,

Glad you were able to figure it out.  I will look into it and see what I can do to get the document updated.

 

Message Edited by Adam_H on 11-25-2008 04:31 PM
Adam H
National Instruments
Applications Engineer
0 Kudos
Message 8 of 11
(6,588 Views)

It is known that a constant wired to a case structure will not help to keep a VI in a non-executed case in memory. That's why constants wired to case structures were turned into controls when opening earlier VIs in LV 8 or newer. You also see this if you display constant folding, the non-executed cases are removed.

But what I don't understand is why the VI doesn't seem to be present in the executable if it is explicitely added as dynamic VI in the build specification. Probably constant folding has "more weight" than adding the VI.

I didn't check, but if you remove the case structure and the SubVI completely from the main VI and just leave it as dynamic VI in the build specification it might work.

 

 

0 Kudos
Message 9 of 11
(6,582 Views)

Hi Dan,

You are correct that the constant wired to a case structure will not bring it into memory. This is the same reason why it is not included in the application. With the constant wired to the case structure there is no possible way for it to ever execute since you cannot edit the block diagram of a .exe. The Application builder is smart enough to see this and not include it because there is no way for it to run. It just helps to keep the application from being any larger than it needs to be.

Adam H
National Instruments
Applications Engineer
0 Kudos
Message 10 of 11
(6,562 Views)