You are viewing limited content. For full access, please sign in.

Question

Question

DocumentProcessor OCREngine Unknown Error and Permissions

asked on December 23, 2015

I am using the following code and getting different results in different environments when run by the same Laserfiche admin user.

 

      LFApplication app = new LFApplication();
      LFServer serv = (LFServer)app.GetServerByName("127.0.0.1");
      LFDatabase db = (LFDatabase)serv.GetDatabaseByName("RepName");
      LFConnection conn = new LFConnection();

      conn.Shared = true;
      conn.UserName = "user";
      conn.Password = "pwd";
      conn.Create(db);

      LFDocument lfDoc = (LFDocument)db.GetEntryByID(1759632);
      LFDocumentPages pages = (LFDocumentPages)lfDoc.Pages;
      OCREngine ocr = new OCREngine();
      ocr.LogFile = @"C:\log.txt";

      pages.UnmarkAllPages();
      pages.MarkPageByIndex(1);
      ocr.OCRMarkedPages(pages);

      conn.Terminate();

 

When run in an EXE using DocumentProcessor80, the imageis successfully OCR'ed.

 

When run in an EXE using DocumentProcessor83, this exception is thrown:

   Message: ""

   ErrorCode: -2147221164

   Inner Exception: null

Log Entry: 23-Dec-2015, 16:15:48, [340]: 3596 -

 

When run from a website in IIS under DocumentProcessor80, this exception is thrown:

   Message: "Access is denied."

   ErrorCode: -2147221230

   Inner Exception: null

Log Entry: none

 

When run from a website in IIS under DocumentProcessor83, this exception is thrown:

   Message: ""

   ErrorCode: -2147221164

   Inner Exception: null

Log Entry: 23-Dec-2015, 16:22:23, [340]: 13204 -

 

It appears that the 8.3 version of OCREngine is having problems running OCR either way and that the 8.0 version has a permissions issue when being run via a website, even though the same LF admin user is being used in both scenarios. Are there NTFS permissions involved with using the OCREngine? We would like to be able to launch OCR when a new page is created from the IIS website. What steps can we take to move forward?

 

The machine I am running on has Laserfiche Client 9.2 installed and can OCR images from the Client window. The DocumentProcessor83.dll version appears to be 8.3.2.685. Please advise if there is additional helpful information I could provide. Thank you.

 

0 0

Answer

SELECTED ANSWER
replied on January 5, 2016

I tried the sample project on a test machine and experienced the same problem. I fixed it by granting DCOM launch & activation permissions to the BPOmniOCR82 and LFOMNIOCR. You can do this through the Component Services mmc snapin:

 

I granted access to the Everyone group but you might want to be more restrictive. It started working after i added permissions to both of these controls (and reset iis).

0 0

Replies

replied on December 24, 2015

The error -2147221164 is "Page does not contain text data.", which should not ever be thrown by the OCREngine class. Can you get a call stack for the exception? 

0 0
replied on December 24, 2015

Is your website running as a x64 process? OCR is x86. Also there are different versions of the OCR engine for DocumentProcessor80, 83 and 92.

0 0
replied on December 28, 2015

The website is running it a 32-bit AppPool and is compiled under x86 architecture.

Here is the exception details when compiled with DocumentProcessor83 and run in an EXE:

System.Runtime.InteropServices.COMException was caught
  Message=""
  Source=""
  ErrorCode=-2147221164
  StackTrace:
       at DocumentProcessor83.OCREngineClass.OCRMarkedPages(Object DocumentPages)
       at LFAnnotateC.Program.RunOCR() in C:\Users\Bryon Poulter\Documents\Visual Studio 2010\Projects\LFAnnotate\LFAnnotateC\Program.cs:line 46
       at LFAnnotateC.Program.Main(String[] args) in C:\Users\Bryon Poulter\Documents\Visual Studio 2010\Projects\LFAnnotate\LFAnnotateC\Program.cs:line 16
  InnerException:
 

The target document has one image page.

0 0
replied on December 28, 2015

I was wrong about the error code, it actually is "Class not registered", which is probably related to the OCR engine not being installed properly.

0 0
replied on December 28, 2015 Show version history

That is a great point. I only had the 9.2 Client, Server, and SDK Runtime installed. I tried to install the 8.3.1 SDK Runtime but got this error:

This update file is not applicable to this system.

I was able to install the fully licensed 8.3.1 SDK and the OCR was then able to work correctly from the EXE. However, this is the error that occurs when run as the same admin user from the website:

System.Runtime.InteropServices.COMException was caught
  HResult=-2147221230
  Message=Access is denied.

  Source=""
  ErrorCode=-2147221230
  StackTrace:
       at DocumentProcessor80.OCREngineClass.OCRMarkedPages(Object DocumentPages)
  InnerException:

Log Entry: 1C3AE654, [274]: 7936 - 1EDB4FA4

 

1. Why wouldn't the 8.3.1 SDK Runtime install?

2. What additional permissions are needed to run OCR from an IIS website?

 

Thank you, again.

0 0
replied on December 28, 2015

Your stack trace indicates you're calling DocumentProcessor80.

1 0
replied on December 28, 2015

Your code above indicates you are trying to write to c:\, which a web application is unlikely to have rights to.  Process Monitor is a great tool for tracking down failures like this.

0 0
replied on December 29, 2015

Thanks, good catch! I forgot to switch the version for the website. Here is the new exception information for the 83 version:

System.NullReferenceException was caught
  HResult=-2147467261
  Message=Invalid pointer
  Source=""
  StackTrace:
       at DocumentProcessor83.OCREngineClass.OCRMarkedPages(Object DocumentPages)
  InnerException:

Log Entry: 2 9 - D e c - 2 0 1 5 ,   0 8 : 5 9 : 4 8 ,   [ 1 6 3 8 7 ] :   5 6 3 6   -   I n v a l i d   p o i n t e r
 

The error is similar to this thread, which ended up being a bug in the 91 version.

0 0
replied on December 29, 2015

The bug mentioned in that post is for images with a large amount of text, does that apply to your image?

0 0
replied on December 29, 2015

No, the image file only has a single word on it. I'm uploading a sample project that works in Visual Studio, but when deployed to IIS in a .NET 4.0 AppPool it throws the Invalid Pointer error. The sample image is included in the attachment, which is actually a zip file.

LFWebC.txt (290.16 KB)
0 0
replied on December 29, 2015

Try monitoring w3wp.exe with Process Monitor while reproducing the error. The registry & disk access might show where it is failing to load the OCR engine.

0 0
replied on December 29, 2015 Show version history

When I run the erroring code, I get these registry entries marked as NAME NOT FOUND in Process Monitor, but they don't show up at all when running the code successfully from Visual Studio. They appear to be user-specific and the profile ID matches the user the IIS AppPool is running under. Why would these resources not be available for this user and can they be granted?

HKU\S-1-5-82-3858710820-3024208786-3596207359-609574889-198938904_CLASSES\BPOmniOCR82.BPProcessEx80

HKU\S-1-5-82-3858710820-3024208786-3596207359-609574889-198938904_Classes\BPOmniOCR82.BPProcessEx80\CLSID

HKU\S-1-5-82-3858710820-3024208786-3596207359-609574889-198938904\SOFTWARE\Laserfiche\DocumentProcessor

HKU\S-1-5-82-3858710820-3024208786-3596207359-609574889-198938904\Software\Laserfiche\Client8\Profile\OCR

HKU\S-1-5-82-3858710820-3024208786-3596207359-609574889-198938904_CLASSES\CLSID\{9D48CA7F-B654-45AF-89AD-2FA6497736D7}

HKU\S-1-5-82-3858710820-3024208786-3596207359-609574889-198938904_CLASSES\Wow6432Node\CLSID\{2633E1AF-1385-49A5-A9D2-FC6BF2D20A0A}

0 0
replied on December 30, 2015

Those registry classes should be found under HKEY_CLASSES_ROOT if the OCR engine has been installed. What does process monitor show when it works through visual studio?

0 0
replied on December 31, 2015

Here's the CSV file of the events captured when run through Visual Studio. It doesn't appear to have any records referencing the HKU registry tree.

Also, I found that when I changed the AppPool identity to a local administrator user, the OCR worked. We would prefer to not grant such privileges to the AppPool.

LogfileVS.txt (496.58 KB)
0 0
replied on January 4, 2016 Show version history

So the IIS app pool user is lacking access to something, the process monitor log should show an 'access denied' somewhere for w3wp.exe.

Edit: there are temp files created during the OCR process, it might be failing to create those.

0 0
replied on January 4, 2016

This is the Process Monitor CSV log showing the moment the call to OCRMarkedPages was initiated and failed, as described in the code from a previous post. I'm not able to see any 'denied' messages. Only the 'NAME NOT FOUND' errors mentioned earlier.

LogfileBAD.txt (44.61 KB)
0 0
replied on January 4, 2016

The OCR engine runs in BPOmniOCR82.exe, try adding that to the process monitor filter. The error must be coming from within that process. If that doesn't show anything, try tracing all processes and have the trace run for the shortest time possible.

0 0
replied on January 5, 2016

I didn't get any events for the BPOmniOCR82.exe, but here is a full capture of the events that occurred during the OCRMarkedPages call.

Are you be able to reproduce the environment on a test system there using the LFWebC.txt (ZIP) file attached to this case? Adding a new Application in IIS pointing to the project in the ZIP file and running in a .NET 4.0 Integrated Application Pool as the ApplicationPoolIdentity user should reproduce the environment I am testing under.
Please let me know what other information I can provide.

0 0
SELECTED ANSWER
replied on January 5, 2016

I tried the sample project on a test machine and experienced the same problem. I fixed it by granting DCOM launch & activation permissions to the BPOmniOCR82 and LFOMNIOCR. You can do this through the Component Services mmc snapin:

 

I granted access to the Everyone group but you might want to be more restrictive. It started working after i added permissions to both of these controls (and reset iis).

0 0
replied on January 5, 2016 Show version history

I added the same permissions for the Everyone group as well as the IUSR user and made sure the 'Enable Distributed COM on this computer' was checked; however, I still get the same error after restarting IIS and rebooting. I also gave Everyone full permissions in the COM Security tab's 'Access Permissions' and 'Launch and Activation Permissions' limits. I also tried giving Everyone permissions to the OmniOCRWrapper82 DCOM object. Is there anything else I may need to enable?

0 0
replied on January 5, 2016

Check the System event log for DistributedCOM errors, my log is filled with errors from when I was attempting to configure the security. When the log mentions a CLSID that is a guid (e.g. {25CA57CC-AB34-4221-95AF-99736B5B84AD}) you can search regedit for that string to find which component it is.

0 0
replied on January 6, 2016

Okay, here was the error I was getting in the System Log:

The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID

{25CA57CC-AB34-4221-95AF-99736B5B84AD}

and APPID

Unavailable

to the user IIS APPPOOL\ASP.NET v4.0 SID (S-1-5-82-794271414-2547205055-1060673776-2579641347-304524694) from address LocalHost (Using LRPC). This security permission can be modified using the Component Services administrative tool.

I saw that the CLSID in the registry did not have an AppID registered with it, which I assume meant it wasn't using the permissions specified in the Component Services. So I added the AppID for the BPOmniOCR82 DCOM Config {BC48F85A-EAE2-432D-9660-1716945BDBA5} as the AppID in the registry for the CLSID {25CA57CC-AB34-4221-95AF-99736B5B84AD} reporting the above error.  

That seems to be working now. I tested on a second machine and had to open the permissions as you outlined earlier and also set this registry key.  Do you think something is failing during the SDK installation?

Thank you very much for your help through this issue; this gives us a way to move forward.

0 0
replied on January 6, 2016

I think the root issue is that IIS is running as a limited user, so the app pool needs to run as a user with more access or the default DCOM permissions need to change:  

0 0
replied on January 7, 2016

I definitely concur with your conclusion. Do you think we will have to expect making that last registry change on most machines? I had to do so on both machines I tested on. Thanks again.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.