Recently I have to use MODI (Microsoft office Document Imaging) to do some OCR, I google some codes, one of them is in csharp from here, like below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
private static string OCR(string fileToOCR)
{
MODI.Document md = new MODI.Document();
md.Create(fileToOCR);
try
{
md.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return "Error!";
}
MODI.Image img = (MODI.Image)md.Images[0];
MODI.Layout layout = img.Layout;
layout = img.Layout;
string result = layout.Text;
md.Close(false);
return result;
}

The code works perfectly at first (System condition is win7+vs2010+MODI(from Microsoft Sharepoint designer)), but the odd thing happens when I reinstall my windows system, the code doesn’t work anymore, it gives me “System.Runtime.InteropServices.COMException, HRESULT:0x80010105 (RPC_E_SERVERFAULT)”. But my system condition is almost the same(win7+vs2010+MODI(from office 2007)).

Then there is another long google process, I have try serveral things

  1. I install vs2008, because the system has vs2008 when the first time succeeded, but not working.
  2. Solutions to HRESULT:0x80010105 (RPC_E_SERVERFAULT) not working
    Then there are no other information related to this. I noticed that the MODI is from different source(MS sharepoint designer and office 2007), so I try to use new MODI in office 2007, and it’s superisingly not working…. It crashes when you try to OCR a tif image, and when I install office 2007 service pack1, everything is fine…

So, if people have this kind of weird problem, try to install office 2007 sp1, that’s probably the solution.


Comments