Search code examples
c#tessnet2

Tessnet2 error in C#


I am using Tessnet2 ocr in C# by following codes:

 tessnet2.Tesseract ocr = new tessnet2.Tesseract();
            ocr.SetVariable("tessedit_char_whitelist", "0123456789");
            ocr.Init(Application.StartupPath + @"D:\\Program Files (x86)\\Visual Studio 2010\\Projects\\AForgeTest2\\AForgeTest2\\tessdata\\", "eng", true);
            List<tessnet2.Word> result = ocr.DoOCR(numberTest, Rectangle.Empty);
            string code = result[0].Text;
            testBox1.Text = code;

but when I run the debug it shows the error message in the 5th line:

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());//the line with error
        }

FileLoadException was Unhandle:
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.


Do you know how to solve this problem?

Kind Regards
Gav


Solution

  • I think changing the target framework of your project from 4.0 to 2.0 will help.

    See: Changing the Target .NET Framework Version or Profile for an Existing Project

    enter image description here