在C#Tessnet2错误(Tessnet2 error in C#)

2019-09-21 04:08发布

我使用Tessnet2 OCR在C#中通过以下代码:

 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;

但是当我运行调试它显示在5日线的错误信息:

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

FileLoadException是未经处理过:
混合模式组件被构建针对运行时的版本“V2.0.50727”,并且不能在没有额外的配置信息的4.0运行时加载。


你知道如何解决这个问题?

亲切的问候
GAV

Answer 1:

我想改变从4.0到2.0的项目将帮助目标框架。

请参阅: 更改目标.NET Framework版本或个人资料的现有项目



Answer 2:

尝试添加

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

您的App.config。

这使您能够引用的DLL,而无需改变你的整个项目的框架版本。



文章来源: Tessnet2 error in C#
标签: c# tessnet2