Home : Deployment : Load GlyphReaderEngine by Reflection
Q10423 - HOWTO: Load GlyphReaderEngine by Reflection

Our GlyphReader engine needs to be loaded by Reflection if being used in a Web App / Web Service / WCF service.

 

You need to prep for this by creating an OcrResources folder in your application /bin/ folder and placing the GlyphReader OCR resources in it. You will also need to go in to your project references and set the Atalasoft.dotImage.Ocr.GlyphReader.dll Copy Local property to false. Copy the Atalasoft.dotImage.Ocr.GlyphReader.dll in to the OcrResources folder as well. That will keep the web project from trying to load it when the application starts.

 

Use this simple method to handle the loading (make sure you set your paths)

 

/// <summary>

/// The GlyphReader Engine needs to be loaded by reflection in a web application...

/// </summary>

/// <returns></returns>

private OcrEngine CreateGlyphreaderEngine()
{
  
try
  
{
     
string ocrPath = Page.MapPath("OcrResources");
     
GlyphReaderLoader loader = new GlyphReaderLoader(ocrPath);

     
string dllPath = ocrPath + "/Atalasoft.dotImage.Ocr.Glyphreader.dll";
      Assembly asm = Assembly.LoadFile(dllPath);
     
Type obj = asm.GetType("Atalasoft.Ocr.GlyphReader.GlyphReaderEngine");
     
ConstructorInfo ci = obj.GetConstructor(new Type[0]);
     
OcrEngine engine = ci.Invoke(null) as OcrEngine;

     
return engine;
  
}
  
catch
  
{
     
return null;
  
}
}

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2017. InstantASP Ltd. All Rights Reserved