简体   繁体   中英

AlprNet hosted in Windows service failed to load

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM