LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call different dll with same name

Hi,all

 

I met a problem when cal diffirent dll with the same name.the project structure can be got from the attachment.The problem is follows:

 

I need to call two different dll with same name with .net, and each of them also call different dlls (name C.dll)with same names. So i build the two top dlls with labview as two new dll LTE_BTS_Test.dll and WCDMA_BTS_Test.dll. And then in my application project ,i call the two diff LTE.dll and WCDMA.dll in a case structure. LTE_BTS_Test.dll and WCDMA_BTS_Test.dll is put in different support folders with their calling dlls.

 

When i run the top exe, WCDMA_BTS_Test.dll can't find and load its calling dlls correctly. But LTE_BTS_Test.dll is ok. but i need to add the LTE support file to OS environment variables "Path" . So , I think maybe the caller dlls is not in the right directory, anyone can help me ,or give me another method to implement my requirement.

 

Thanks a lot

0 Kudos
Message 1 of 5
(3,565 Views)

Windows does not allow to load different DLLs with the same name into the same process at the same time.

 

You have two options:

 

1) Create several processes (applications) that load a specific DLL into memory and use interprocess communication (TCP/IP, file IO, shared memory, etc.) to communicate between these processes.

 

2) If you can live with the different parts not being in memory at the same time, you can create different LabVIEW VIs that access these components and load these VI's dynamically with VI Server whenever needed.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 5
(3,547 Views)

Hi,rolfk

 

Thanks for your answer, but i'm not call the dlls with same same at the same time. I build two projects and package them in diffrent new dlls with diffrent name .

Then in the top Vi project i call them by the new dlls i build. Because in the top vi project ,these two dlls is in the case structure,they will not be called at the same time when it runs.

Do you think the method would work? 

0 Kudos
Message 3 of 5
(3,538 Views)

If they are in a case structure they are probably loaded into memory at the same time, which is the problem. You might be able to get away with calling them dynamically, where they would only be loaded into memory when called. Search on dynamically loaded or "plug-in" to see examples.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 4 of 5
(3,527 Views)

 


@Sonic_N wrote:

Hi,rolfk

 

Thanks for your answer, but i'm not call the dlls with same same at the same time. I build two projects and package them in diffrent new dlls with diffrent name .

Then in the top Vi project i call them by the new dlls i build. Because in the top vi project ,these two dlls is in the case structure,they will not be called at the same time when it runs.

Do you think the method would work? 


 

No! It's not the fact that the DLLs will  be called simultanously or not that is the problem, but the fact that you would need to load both DLLs into memory at the same time. Windows doesn't allow that. But a DLL referenced in the Call Library Node is loaded as soon as that Call Library Node is loaded by LabVIEW, and with that DLL all other DLLs that are referenced by this DLL.

 

So the only real solution is to not load both VIs at the same time but only one at a time. And you can do that with VI Server by opening a reference to the according VI and then calling it through the Call by Reference function node and when you close the VI Reference the VI is unloaded again. Works perfectly BUT laoding a VI and all its DLL hierarchy takes a lot of time in comparison to a single DLL function call, so this method will have significant impact on performance. However there is no other way unless you can avoid any two DLLs to have the same name.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 5
(3,526 Views)