NetworkInterface Error on startup when using Init.d

Hello all.
I am using a script as part of the init.d start up to launch a daemon console app on Linux Raspberry Pi. When the script is run, the app will start but will not work because the code below errors.

// ******  This is where the error occurs
Dim n As NetworkInterface = System.GetNetworkInterface(0)   //Get the NetworkInterface object for the selected item

If the app is started manually after boot, it runs fine without any errors.

This is the init.d scritp:

[code]#!/bin/sh

BEGIN INIT INFO

Provides: axcys-embedded-interface

Required-Start: $local_fs $syslog $time $network

Required-Stop: $local_fs $syslog $time $network

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Axcys Embedded Interface

Description: Axcys Embedded Interface

END INIT INFO

case $1 in
start)
start-stop-daemon --quiet --chuid pi --start --exec /home/pi/Public/axcys/gate/AxcysEmbeddedInterface
;;
stop)
start-stop-daemon --quiet --chuid pi --stop --exec /home/pi/Public/axcys/gate/AxcysEmbeddedInterface
;;
restart|force-reload)
$0 stop && $0 start
;;
status)
ps u -U pi
;;
*)
echo “Usage: sudo service axcys-embedded-interface {start|stop|restart|force-reload|status}”
;;
esac[/code]

Note that there are 2 other scripts virually identical to this one, for two other apps I have that I want started and controlled. They do not have the same problem. I am thinking it has to do with the startup order but cannot really tell. The required start objects are the same for all three. But apparently the $network one is missing something.

Can anyone suggest what other objects may not be ready, that have to do with networking, so I can add them to the script?
Thanks,
Tim

It sounds like your app is being launched before the network stack starts.

Try renaming your script to have a “z” as the first char and try again.

Hi Greg.

That did not fix it. Any other ideas?
Thanks,
Tim

What is the error? Maybe you could have your app code call GetNetworkInterface again after a short wait period which might give the startup process enough to to init the network stack.

Hi Paul.
I thought about doing that check and wait, but was waiting to see if I could fix first through start up. The error is an OutOfBounds Exception when the System.GetNetworkInterface(0) is performed.

Dim n As NetworkInterface = System.GetNetworkInterface(0

Hi all,
I added a timer and have timer check if the network is up or not. Once up, the app proceeds.

Thanks for the work around idea.
Tim