Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues bundling NI-CAN dlls along with my CAN application.

When I try to run my CAN application on a system on which NI-CAN s/w is not installed. It gives the error
"Application failed to initialize properly (0xc0000142)" [error message is attached]. I included all the NI-CAN DLL's[list got using the Depends utility] under my application installer. It copies the DLL's to the C:\winnt\system32 directory.

Am I missing any step like registering the DLL's, etc., If so what r the DLL's to be registered ...

Can anyone please help ...
0 Kudos
Message 1 of 4
(3,707 Views)
Hi,

Just installing some (or all) DLLs that are installed with the NI-CAN driver does not make the NI-CAN driver work. Each version of the NI-CAN driver also registers services with the OS and depends on certain versions of other National Instruments components (e.g. the Measurement and Automation Explorer) in order to work.

Trying to replicate this manually might be successful on one system (because it fulfills all dependencies already), but might fail on another one.

Because of this, I strongly recommend to use the NI-CAN installer to deploy the NI-CAN driver on a target system.

-B2k
Message 2 of 4
(3,703 Views)
Hi B2k,

Thanks for responding to my message.

Your suggestion is very much valid and I would have accepted it if the mentioned error had occured when my application was trying to call[runtime] any of the NI-CAN api's.

But since this error message is popping up as soon as my application is executed.

Aim is that; My NI-CAN application should run fine on the target computer[on which no NI-CAN hardware or software is installed] as long as it is not firing/calling[runtime] any of the NI[NI-CAN] api's.

The reason for such requirement is; My application can run in two modes. Real mode[with h/w installed] 2. Emulation mode[without any CAN h/w installed] it emulates the CAN protocol.

So one more issue is that neither I can recommend my client to download and install NI-CAN software[112MB] nor can I supply NI-CAN software with my application setup[because of its size]when he just wants to run it in emulation mode.

So the only thing i wanted to know is the minimum set of components that needs to be supplied with my application that would enable it to run fine as long as its not calling[runtime] any of the NI[NI-CAN] api's.

regards
Vinnayak
0 Kudos
Message 3 of 4
(3,700 Views)
Hi Vinnayak

What programming language do you use? If it’s a LabVIEW, this would be tricky to work around. When LabVIEW loads (not executes) a VI, it also loads all dependent DLLs to check, if they are all executable. That way you avoid crashes or hangs if the VI already runs and then it turns out that a particular DLL is missing or doesn’t provide the required function. You can observe this, when you open LabVIEW (nothing else open) and drop a CAN (or DAQmx) VI on the diagram. There is a small delay before the VI actually gets onto the diagram which is caused by loading the required ‘DLL chain’.

If you know, that you are not going to execute any code that calls into the NI-CAN DLLs, you could create a stub DLL that provides all the function declarations (ncOpen(), ncClose(), etc.) that your VI calls, but has no code in it.
This is quite a bit of work, depending how many different functions are used.

If you are not using LabVIEW, you could load the NI-CAN functions dynamically using the Win32 functions getProcAddr() and loadLibrary(). That way the NI-CAN DLL is only loaded when it is actually used.

Copying individual DLLs will not work as the NI-CAN driver DLLs not only depend their own Win32 service, but other services running which in turn have their own dependencies.

-B2k
Message 4 of 4
(3,682 Views)