Question

I am trying to OCR an image in C# using MODI. I get the following error:

System.Runtime.InteropServices.COMException (0xC6C80001): Object hasn't been initialized and can't be used yet 
at MODI.DocumentClass.OCR(MiLANGUAGES LangId, Boolean OCROrientImage, Boolean OCRStraightenImage)

Here is the code I use.

MODI.Document mDoc = new MODI.Document();
mDoc.Create(imageFilePath);
mDoc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
MODI.Image image = (MODI.Image) mDoc.Images[0];
String imageText = image.Layout.Text;

Here is what I noticed. It runs without any problems on Windows 2003 where I developed the code. When I move all related code into another machine with Windows 2008 and attach IIS to that code that is when I get an error.

Is it possible that there are any dependencies on the server where the code was created and compiled?

Any idea what can cause the exception? Any help would we appreciated. Thanks!

No correct solution

OTHER TIPS

I ran into a similar problem with a service that makes use of MODI. The service ran correctly on my local machine and our test environment, but when invoking the service from production machines (Windows 2003 and 2008 R2) I was seeing the following error:

  • Server was unable to process request. ---> Object hasn't been initialized and can't be used yet.

I was able to fix this by going into IIS and switching the service's application pool identity to NetworkService. The previous identity account we were using had more restrictive permissions, so MODI was not being correctly accessed and loaded even though it was installed.

I had the same problem and managed to fix it, my scenario was the following:

I had to work on an application that was using MODI, but I did not have MS Office 2007 installed on my machine so I decided to download it. Since I did not want to install every component I went on custom installation and only checked Microsoft Office Document Image option... After that I ran the application and got the same error as the OP mentioned.. After trying to do all the methods also the one mentioned above it still did not solve my problem.. Then I tried to run MODI from my pc, and then I realised the OCR is missing. So I went back to the installer and realised I can expand MODI and the OCR feature was not ticked. Ticking it and restarting the pc solved it for me. I know probably this wont be most peoples problem but it might save a few careless people like myself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top