문제

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

도움이 되었습니까?

해결책

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

다른 팁

Try adding

<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
</configuration>

to your App.config.

This enables you to reference that DLL without having to change your entire project's framework version.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top