I decided to use tessnet2 library for my Windows Mobile 6 project. Unfortunetly while I am trying to compile it, it throws an error:
The best overloaded method match for 'tessnet2.Tesseract.GetThresholdedImage(System.Drawing.Bitmap, System.Drawing.Rectangle)' has some invalid arguments
The type 'System.Drawing.Rectangle' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
OK, I know. Add reference to the assembly. The problem is, that I did it. I add reference by 'Add Reference' in Solution Explorer (System.Drawing), and I even have it declared as 'using System.Drawing'.
Intellisense works without any problem. When i write 'rect' it automaticlly shows me the list with 'Rectangle' structure on top.
What is the problem? The assembly is added, even intellisense sees it, why doesn't the compiler?
Just looking at it, there's no way this is going to work in the Compact Framework. First off the site explicitly says
Tessnet2.dll needs Visual C++ 2008 Runtime
Well, that means it was built for the desktop. It's not going to work on a WinMo device for many reasons, but suffice it to say that you would have to recompile it for the right processor and using the right runtimes. If it uses anything like inline assembler this is going to make porting it really, really challenging.
If you get the tessract library built, you still can't use the tessnet2 managed library.
It's a Visual Studio 2008 C++/CLI project
This means it's a managed C++ project. Managed C++ is not supported by the COmpact Framework. So you'd have to port that to C# or write a separate P/Invoke wrapper that calls the tessract library functions.
The compact framework and standard framework are 2 different code bases that exposes a similar API. That is why intellisense 'worked' but the compiler 'complained'.
Your 3rd party OCR framework needs to reference the CompactFramework. Download the source for Tessnet2. Replace the referenced framework assemblies with compact framework assemblies. You'll have to browse for them and find them in "C:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE".
来源:https://stackoverflow.com/questions/2162515/cant-find-referenced-assembly-when-compiling-for-windows-mobile