AlprNet hosted in Windows service failed to load

71 Views Asked by At

When I run this code under my account in Visual Studio debugger

_alprNet = new AlprNet("eu", "openalpr.conf", "runtime_data");
if (!_alprNet.IsLoaded())
{
    Tools.LogError("!!! OpenALPR failed to load.");

It works OK and AlprNet loads.

But when I install the Windows service and start this service I get "!!! OpenALPR failed to load." with no additional information.

I have all the DLLs and the runtime_data in the folder where my windows service's exe file is installed, exactly the same way as it is in bin\Debug folder.

How to find the reason why AlprNet failed to load?

1

There are 1 best solutions below

0
Vojtěch Dohnal On BEST ANSWER

In case it is useful for anyone:

This line in OnStart method before creating new AlprNet fixed the problem:

System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

https://stackoverflow.com/a/10385563/2224701

Apparently the non .NET DLLs dependencies could not be solved without this.