I am trying to Use FCEngile in my webservice by loading the FCEngine.DLL library. Once i am rtying to load the engine its throwing an exception thet "FC Engine has to be loaded on the same thread as it was initialized". kindly advice hiw to over come the same. Please have a look the codes for your reference.

  1. Web method public void ProcessImage(byte[] document,string ImageName, string DocumentType, string DeviceId) { string serializedXML = string.Empty; try {
    if (document.Length > 1 && !string.IsNullOrEmpty(ImageName) && !string.IsNullOrEmpty(DocumentType)) { DeviceID = DeviceId; ImgName = ImageName; InitDefaults(int.Parse(DocumentType)); ImgPath = sampleCollection + DeviceId + "//" + ImageName + ".png"; DirectoryInfo dirInfo = new DirectoryInfo(sampleCollection + DeviceId); if (dirInfo.Exists == false) Directory.CreateDirectory(sampleCollection + DeviceId); if (File.Exists(ImgPath)) { File.Delete(ImgPath); FileStream fStream = new FileStream(ImgPath, FileMode.OpenOrCreate); fStream.Write(document, 0, document.Length); } else { FileStream fStream = new FileStream(ImgPath, FileMode.OpenOrCreate); fStream.Write(document, 0, document.Length); } processCurrentImageFile(); }
    } catch (Exception Exp) { if (Exp.InnerException != null) new ACRException("PowerExtractionService.ProcessImage(): " + Exp.InnerException.ToString(), ACRException.ErrorType.Error); else { new ACRException("PowerExtractionService.ProcessImage(): " + Exp.Message, ACRException.ErrorType.Error); } }
    }

  2. method process Current Image File

private void processCurrentImageFile() { try { if (engine == null) { engine = loadEngine(); } if (processor == null) { processor = engine.CreateFlexiCaptureProcessor(); processor.AddDocumentDefinitionFile(templatePath); } else { processor.ResetProcessing(); } processor.AddImageFile(ImgPath); IDocument document = processor.RecognizeNextDocument();
} catch (Exception Exp) { if (Exp.InnerException != null) new ACRException("PowerExtractionService.processCurrentImageFile(): " + Exp.InnerException.ToString(), ACRException.ErrorType.Error); else { new ACRException("PowerExtractionService.processCurrentImageFile(): " + Exp.Message, ACRException.ErrorType.Error); } } }

  1. Method Load Endgine

static IEngine loadEngine() { IEngine engine = null; try { int hresult = InitializeEngine(GetDeveloperSN(), null, null, out engine); Marshal.ThrowExceptionForHR(hresult); } catch (Exception Exp) { if (Exp.InnerException != null) new ACRException("PowerExtractionService.loadEngine(): " + Exp.InnerException.ToString(), ACRException.ErrorType.Error); else { new ACRException("PowerExtractionService.loadEngine(): " + Exp.Message, ACRException.ErrorType.Error); } } return engine; }

    public static string GetDeveloperSN()
    {

        return "xxxxxxxxxxxxxxxxxxxxxx";
    }

asked 22 Jul '14, 12:02

Hari's gravatar image

Hari
112

edited 22 Oct '15, 14:02

Oksana%20Serdyuk's gravatar image

Oksana Serdyuk ♦♦
1.5k16

Thanks for the support. We are using abbyy flexicapture engine 10.5 for OCR extraction and we need to run the same on our web service. i tried the same code for loading the engine in Winforms and it was working perfectly well and the same code in webservice giving the error. Can u please let me know the linitialization of engine by InprocLoader or OutprocLoader.

The load constructor of IengineLoader take two paramenters. 1.serial number-is this the licese number of abbyy flexicapture engine??? 2. Appdate path--is the the dll path of FCEngine.dll???

Kindly advice us regarding the same.

(22 Jul '14, 16:24) Hari

As the first parameter serial number of developer license to FCEngine should be passed, ans as thew second parameter you can specify path to the FlexiCapture Engine data folder, please see more details in Help → API Reference → Objects → Engine Loaders → IEngineLoader → Load method.

(22 Jul '14, 17:12) SDK_support ♦♦

Till FCEngine 10, it was impossible to run and use Engine object in several threads, but starting from FCEngine 10 this feature becomes possible with the help of InprocLoader or OutprocLoader.

If you use the InitializeEngine (InitializeEngineEx) function for loading, using Engine object in several threads is impossible. In this case the methods of all ABBYY FlexiCapture Engine objects should be called only from the thread in which Engine object was created.

Please see more details of its implementation in Help → Frequently Asked Questions → Is it posssible to run and use Engine object in several threads?

link

answered 22 Jul '14, 16:02

SDK_support's gravatar image

SDK_support ♦♦
2763

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×10
×2

Asked: 22 Jul '14, 12:02

Seen: 1,317 times

Last updated: 22 Oct '15, 14:02

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal