charlesw / tesseract-ocr-dotnet

Other
31 stars 35 forks source link

Exception when running VS2008 console app (The specified module could not be found: 0x8007007E)) #2

Closed tedeff closed 12 years ago

tedeff commented 12 years ago

Hi thanks very much for creating this fork - just was I was looking for!

When I run the VS2010 version of the console app it works fine. However when I run the VS2008 version, I get the following error immediately (before even hitting a breakpoint at the start of Main():

The specified module could not be found. (Exception from HRESULT: 0x8007007E)

at tesseractconsole.Program.Main(String[] args)\r\n
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n
at System.Threading.ThreadHelper.ThreadStart()"

I've searched the tesseractdotnet issues for this, and the only possible solutions I've seen are these posts here: http://code.google.com/p/tesseractdotnet/issues/detail?id=1#c60 http://code.google.com/p/tesseractdotnet/issues/detail?id=1#c67

I've tried ensuring, as suggested in the second post that the console app is configured to "x86" and not "AnyCPU" but it doesn't appear to make any difference, and I'm afraid I don't understand the what is meant by "try add "leptonlibd.dll" in the output file." in the first post .

Any suggestions?

charlesw commented 12 years ago

Can you add the full exception details (i.e. Exception -> copy details) and any relevant windows event log messages (if any). I do recall having similar issues/exceptions if the VC++ run-time (for VS 2008) wasn't installed. Are you running the from within VS 2008 in which case this shouldn't be the problem.

I also doubt that its caused by leptonlib as this should be being embedded into the dll.

tedeff commented 12 years ago

Hi thanks for your reply and apologies for not getting back to you sooner.

After some playing around I realised that I was using the Debug build of tesseract.dll, which doesn't use the statically linked version of leptonlib. The Release version does use the static version of leptonlib and the console app worked straight out of the box.

I experimented with changing the Debug version of tesseract.dll to use the debug version of the static libs but couldn't get it to compile, so in the end what I did to get the Debug version to run was to add a Post-Build event to the tesseractconsole project to copy the required liblept168d.dll into the output folder:

Debug folder: tesseract-ocr-dotnet\vs2008\bin\x86\Debug must contain: tesseractconsole.exe tesseract.dll liblept168d

Release folder: tesseract-ocr-dotnet\vs2008\bin\x86\Release must contain: tesseractconsole.exe tesseract.dll

I'll create a pull request of the changes I made to the projects to achieve this, so you can take a look.

Here are the full exception details as you requested, but they aren't much more revealing:

System.IO.FileNotFoundException was unhandled Message="The specified module could not be found. (Exception from HRESULT: 0x8007007E)" Source="tesseractconsole" StackTrace: at tesseractconsole.Program.Main(String[] args) at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

charlesw commented 12 years ago

Confirmed that this issue has been fixed by pull request #3 from tedhols/master.

Thanx for the fix.