尝试执行OCR示例时C#异常

时间:2019-06-12 13:40:20

标签: c# ocr

我正在尝试使用CnetSDK在C#上进行OCR应用程序。我有一个例外

  

“引发异常。---> System.TypeLoadException:无法从程序集'System.Web,版本= 4.0.0.0,区域性=中性加载类型'System.Web.HttpServerUtility'。”

我尝试了许多类似在线文章中建议的方法,但似乎无济于事。有人可以让我知道他们是否有主意吗?

        // Create an OCR Engine instance.
        OcrEngine OCRLibrary = new OcrEngine();

        // Set the absolute path of tessdata.
        OCRLibrary.TessDataPath = "Desktop:/tessdata/";

        // Set the target text language you want to recognize.
        OCRLibrary.TextLanguage = "eng";

        // Recognize text from image file.
        string Imagetext = OCRLibrary.PerformOCR(@"Desktop:/driving.jpg");
        System.Console.WriteLine(Imagetext);

1 个答案:

答案 0 :(得分:0)

您能分享一些您尝试过的东西吗?

该错误似乎是试图引用system.web dll之一,您的项目是Framework还是Core?在CnetSDK网站上,它确实说它与.Net Framework 4.0或更高版本兼容。

enter image description here

检查您的项目是否是.Net Framework> 4.0项目

System.Web不是.net核心的一部分,因此将无法使用它。 https://github.com/dotnet/core/issues/838

希望有帮助!