We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

The type initializer for ' ' threw an exception

Just trying to get OCR set up, and am receiving an error when running AsposeOcr.RecognizeImage() using a MemoryStream.

Exception:System.TypeInitializationException: 'The type initializer for ‘ ’ threw an exception.’

Inner Exception 1: TypeInitializationException: The type initializer for ‘Microsoft.ML.OnnxRuntime.NativeMethods’ threw an exception.

Inner Exception 2: EntryPointNotFoundException: Unable to find an entry point named ‘OrtGetApiBase’ in DLL ‘onnxruntime’.

App is .Net 4.7.2, and I installed the Microsoft.ML.onnxRuntime NuGet package, but that made no difference.

Image with code and exception
image.png (16.9 KB)

@rtheil

Would you please share the environment details i.e. OS Name and version. Also, please try using the image from a path and see if the exception still occurs. Please share the sample image with us so that we can test the scenario in our environment and address it accordingly.

Sure thing. Windows 10.0.19042.630.

Image from path results in the same error.

Here’s the image I’m trying to work with:
image.jpg (97.0 KB)

We have used Aspose.barcode for years, so I’ve got all the license stuff set up properly. This is an odd one though and all my research and potential solutions have resulted in the same exception.

@rtheil

The issue seems related to your specific environment as we were unable to notice this issue at our side. It is quite possible that OnnxRuntime is unable to run correctly due to some reasons at your end. However, we have logged an investigation ticket as OCRNET-292 in our issue tracking system for further analysis against this case.

We will further look into the details of this ticket and let you know as soon as it is resolved. Furthermore, we will also request for some more information in case we need it. Please give us some time.

We are sorry for the inconvenience.

Sounds good. For now I am attempting to utilize the cloud version, which seems to be working ok so far.

I just ran into the same issue, but installing the updated Microsoft.ML.OnnxRuntime solved the problem for me.

@lbuckland

Thanks for sharing the solution worked for you. It would really help others facing the similar issue.