1

我有一个使用Tessnet2的应用程序。当我尝试调用其 Init 方法时,应用程序失败。
失败太可怕了——没有例外(ANY),没有任何错误痕迹,甚至没有“发送报告”窗口。该应用程序的进程刚刚删除

有问题的代码是:

Recogniser = new Tesseract();
Recogniser.SetVariable("tessedit_char_whitelist", Whitelist);
Recogniser.SetVariable("unlv_tilde_crunching", false);
Recogniser.Init(null, "eng", false); // FAILURE IS HERE

几个可能有用的注释:

  • Tessnet2 需要Visual C++ 2008 运行时。不确定它是否应该是 msvcm90.dll、msvcm80.dll。
  • 该应用程序是桌面 WPF。
  • 开发环境:VS 2008 SP、.NET 3.5 SP1
  • 它以前工作过(我想我添加了 Web 引用来使用 SOAP Web 服务,但我试图删除它但没有结果)。
  • 单元测试运行良好,没有失败

从这些观察来看,这听起来像是 WPF 应用程序本身的问题。

我只有一条信息是调试期间的输出:

'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'D:\...\bin\Debug\OcrForm.WinApp.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml.Linq\3.5.0.0__b77a5c561934e089\System.Xml.Linq.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Data.DataSetExtensions\3.5.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\UIAutomationProvider\3.0.0.0__31bf3856ad364e35\UIAutomationProvider.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\WindowsBase\3.0.0.0__31bf3856ad364e35\WindowsBase.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\PresentationCore\3.0.0.0__31bf3856ad364e35\PresentationCore.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\PresentationFramework\3.0.0.0__31bf3856ad364e35\PresentationFramework.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.  
The thread 0x1784 has exited with code 0 (0x0).
The thread 0x1144 has exited with code 0 (0x0).
The thread 0x16a4 has exited with code 0 (0x0).
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'D:\...\bin\Debug\OcrForm.WinApp.exe', Symbols loaded.
Step into: Stepping over non-user code 'OcrForm.WinApp.App.App'
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Step into: Stepping over non-user code 'OcrForm.WinApp.App.InitializeComponent'
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\PresentationFramework.Classic\3.0.0.0__31bf3856ad364e35\PresentationFramework.Classic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x374 has exited with code 0 (0x0).
The thread 0x13cc has exited with code 0 (0x0).
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'D:\...\bin\Debug\OcrForm.dll', Symbols loaded.
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'D:\...\bin\Debug\Commons.dll', Symbols loaded.
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'D:\...\bin\Debug\tessnet2_32.dll', Symbols loaded.
'OcrForm.WinApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_6f74963e\msvcm90.dll'  

应用程序失败时的最后一块:

The program '[5384] OcrForm.WinApp.vshost.exe: Managed' has exited with code 1 (0x1).

更新:我检查了事件日志。没有任何带有“SideBySide”来源的条目。下面只有与该问题相关的条目,但不幸的是它并没有告诉我很多信息:

Event Type: Error
Event Source:   .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID:   5000
Date:       28/10/2009
Time:       4:07:57 PM
User:       N/A
Computer:   ARGO11
Description:
EventType clr20r3, P1 ocrform.winapp.exe, P2 1.0.0.0, P3 4ae7d16c, P4 ocrform, P5 1.0.0.0, P6 4ae1333f, P7 10f, P8 1, P9 system.typeinitialization, P10 NIL.

提前感谢您的任何提示。

4

2 回答 2

1

查看 Windows 系统事件日志(开始->设置->控制面板->管理->事件查看器)。您可能会在 Windows SideBySide 管理器中找到条目。

输出的最后一行显示来自 SideBySide 的 dll 已加载。

我最近有类似的问题。在我们查看事件日志之前,没有提示失败原因。

于 2009-11-02T10:05:26.593 回答
0

我解决了这个问题。

简短回答:使用SaveFileDialog后,应用程序的工作目录已更改。这导致 Tesseract 无法找到相关文件。

我为此做了几件事:

  1. 创建了一个使用 Tessnet2 的新 WPF 应用程序。
  2. 启动它->它以完全相同的方式失败。
  3. 我发现我错过了添加 tesseract 所需的文件。
  4. 添加了它们 -> 应用程序开始工作。

比转移到我的应用程序:
我检查了 tesseract 所需的文件。一切就绪且有效。

因此,必须有其他与无法访问文件相关的事情:

  1. 没有权限。
  2. 位置不正确。

检查了第一个 - 一切都很好。
检查第二个所有文件都在正确的位置相对于应用程序当前目录

看到重点了吗??
但事实证明这些文件应该与应用程序位于同一工作目录中。

使用SaveFileDialog后工作目录已更改!

如果我不使用该应用程序的对话框。
我怎么可能从所有“错误信息”中弄清楚这一点......
希望这会对某人有所帮助。

于 2009-11-04T06:09:42.693 回答