Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish single file doesn't load the leptonica dll (Exception has been thrown by the target of an invocation) #636

Open
w4po opened this issue Feb 22, 2023 · 3 comments

Comments

@w4po
Copy link

w4po commented Feb 22, 2023

Hello,
I can't get my app to work if I publish it as a single file using the visual studio Publish tool.

I think the issue is somehow can't locate the runtime folder (x86, x64),
even though I made sure that both of them and the tessdata folder are located in the same folder as the executable.

BTW, The app works just fine if not built as a single file.

To reproduce the issue:

Either build as a single file or move the runtime files (leptonica-1.82.0.dll, tesseract50.dll) anywhere other than the (x86, x64) folder.

How to fix:

I think if you allow specifying a custom location for the runtime folders (x86, x64) that should fix it.

Stack Trace:

at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at InteropDotNet.InteropRuntimeImplementer.CreateInstance[T]()
at Tesseract.Interop.LeptonicaApi.Initialize()
at Tesseract.Interop.TessApi.Initialize()
at Tesseract.Interop.TessApi.get_Native()
at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode, IEnumerable`1 configFiles, IDictionary`2 initialOptions, Boolean setOnlyNonDebugVariables)
at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode)
@w4po
Copy link
Author

w4po commented Feb 22, 2023

I found a fix:

TesseractEnviornment.CustomSearchPath = Environment.CurrentDirectory;

But you still have to put the x86 and x64 in the same folder of your executable.

@charlesw
Copy link
Owner

charlesw commented Feb 24, 2023 via email

@benquan
Copy link

benquan commented Jun 13, 2023

Charles, On a .NET application these files get added and bundled to the project automatically. On framework you must add them manually. Is there a way to add them automatically like in .NET?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants