LabVIEW Project Providers

Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.

'Add Item From Memory' Issue

Hi

I am trying to add an Item to the Project via Item_OnCommand using the AddItemFromMemory method on a Class I create (using LVClass.Create method).

The code works fine when running 'normally in LabVIEW' however, when this code is called through the Provider I get an Error:

Error 1004 occurred at an unidentified location

Possible reason(s):

LabVIEW:  The VI is not in memory.

If I save the newly created Class to disk then use the AddFile method, then it works.

The Error is generated immediately after the AddItemFromMemory method is called.

AddItemFromMemory.png

I maybe doing something wrong but I am thinking this may have something to do with the Context?

Can anyone offer advice?

Cheers

-JG

Certified LabVIEW Architect * LabVIEW Champion
0 Kudos
Message 1 of 4
(379 Views)
3 REPLIES

Re: 'Add Item From Memory' Issue

Hey Jonathon,

I definitely think it is a context issue like you mentioned.  Since you are creating your LVClass with no reference wired, it is created in whatever context the VI is running in, which in the case of the provider VI is the NI.LV.MxLvProvider context.  The AddItemFromMemory method is running in the context of the Item, which I assume is the My Computer context in the project.  The trick to get around this is to explicitly create the LVClass in the same context as the Item input.  To do this all you need to do is get the Application Reference from the Item input and wire that to your method node up top. 

Get App Reference.png

Hopefully this SHOULD work, but let me know if not and I'll try to think of some other ideas. 


David

Message 2 of 4
(336 Views)

Re: 'Add Item From Memory' Issue

I swear I was playing around with the App instance last night and I was still getting an error.

Oh well, its working now - thanks!

Certified LabVIEW Architect * LabVIEW Champion
0 Kudos
Message 3 of 4
(336 Views)
Highlighted

Re: 'Add Item From Memory' Issue

No problem.  I understand how that is.  I have to take my car in this week for a check engine light, and I assure you that the light will go off as soon as I drive into the parking lot of the dealership...

Good luck, and happy LabVIEWing!

Message 4 of 4
(336 Views)
Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.