Tesseract - Add reference does not works - c#

I'm following the steps:
Download binary here, add a reference of the assembly Tessnet2.dll to your .NET project.
Download language data definition file here and put it in tessdata directory. Tessdata directory and your exe must be in the same directory.
Look at the Program.cs sample
if I call the class from lib using:
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
I'm getting the following error:
Name Namespace or type 'tessnet2' could not be found.
Need a using directive or a set of reference
Modules (assembly)?
How I solve this?
Thanks!

There are two DLL versions for tessnet2: 32- and 64-bit. Make sure you add the correct one to your project. Check VietOCR.NET 2.0x for a working example of using tessnet2.

The error says that it can't find the namespace - even though you've added a reference to it, do you either name it using the full namespace, or can you include it as a "using" at the top of the cs file?
For reference, the translated error (from Portuguese) is:
Namespace or type 'tessnet2' could not be found. Need a using
directive or an assembly reference (assembly)?

Related

Missing System.Devices library and problem constructing AQS strings

What I am trying to achieve is to scan my loacal network for connected devices. I learned that I need to construct a selector and pass it to function
DeviceInformation.FindAllAsync()
for example. The problem is, however, all of these require the System.Devices namespace e.g.
System.Devices.InterfaceClassGuid:="{2eef81be-33fa-4800-9670-1cd474972c3f}"
and I get such an error: "Error CS0234 The type or namespace name 'Devices' does not exist in the namespace 'System' (are you missing an assembly reference?)".
I suspect this is because I'm missing the library somehow. I tried
using System.Devices
but again namespace does not exist in the namespace. I also tried adding it in the Reference Manager but there is no such library either.
I couldn't find the library online.
Also I am not exactly sure how to construct AQS strings.
DeviceInformationCollection collection = await DeviceInformation.FindAllAsync(DeviceClass.ImageScanner);
This is ok but showing local devices only.
var selector = System.Device.Aep.ProtocolId:= "{37aba761-2124-454c-8d82-c42962c2de2b}";
This gives errors, one with namespace and more syntax-bound.
I expect passing a selector to the function but I'm missing the namespace System.Devices and AQS strings don't work.
It seems like this is not a namespace. They are windows properties, please check windows properties.
System.Devices is not a namespace. They are Device information properties. if your want enumerate device, you need use DeviceWatcher to capture device that match condition.
DeviceWatcher deviceWatcher = DeviceInformation.CreateWatcher(
"", // AQS Filter string
null, // requested properties
deviceInfoKind);
And this is official code sample that you could refer.
"DeviceWatcher" sounds great — it says:
"Build the sample
Start Visual Studio and select File > Open > Project/Solution.
Go to the directory to which you unzipped the sample. Then go to the subdirectory containing the sample in the language you desire - either C++, C#, or JavaScript. Double-click the Visual Studio Solution (.sln) file.
Select the appropriate target: x86, x64, ARM. Press Ctrl+Shift+B, or select Build > Build Solution.
Ah, but then the catch comes:
"The type or namespace 'System' could not be found."
It supplies "using System;" in all the header lines, it but demands "using Windows;" and rejects all the others.
Go figure —

Why am I getting the following error when compiling this assembly?

I'm attempting to use the following command line command to compile an assembly of the code from my project:
C:/"Program Files"/Unity/Editor/Data/Mono/bin/gmcs
-target:library -out:C:/Users/Austin/Desktop/PixelExpanse.dll
-recurse:C:/Users/Austin/Desktop/Projects/Repos/trunk/PixelExpanse/SpaceColonyRefactor/Assets/Source/*.cs
-d:RUNTIME -r:C:/"Program Files"/Unity/Editor/Data/Managed/UnityEngine.dll
As you can see, I am, I believe, correctly referencing the UnityEngine.dll.
The code that would be compiled contains references to UnityEngine.UI and UnityEngine.EventSystems. But when I run the above command, I get the following compile error:
error CS0234: The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine'. Are you missing an assembly reference?
From what I have been able to find through googling, it SEEMS like an error people were getting when using a pre-4.6 assembly, because thats when EventSystems and UI were both introduced. But I don't know how I could be missing that in the dll I'm referencing as Unity 5 is the only version that has ever touched this computer.
As a side note, I have posted this question to Unity Answers and have yet to receive a response. I expect it's because assembly compilation is beyond the scope of what most users there choose to undertake. Hence my asking it here.
The namespace UnityEngine.EventSystems actually appears in UnityEngine.UI.dll and not UnityEngine.dll so it seems you need to reference the former too when compiling manually from the command-line. Unity projects have this by default (see below).
This is verified by opening up the assembly in your reflector tool of choice, here I am using JetBrains dotPeek:
This is how my test project appears with default Unity references. Note that by default a reference to UnityEngine.UI already appears in the Unity-created project:
When I built my Windnows desktop app via Unity, the above dlls appeared in:
<drive>:<projectOutFolder>\<projectName>_Data\Managed
You can try:
right click on "project panel", and after "Reimport All".
It's can be happen due to switch between platforms, e.g. IOS, or Desktop.. thus, folrders are deleted by became unecessary..
Solve for me: Unity 5.2, Win 7, 32bits;
Good luck!
I checked the UnityEngine.dll and the Eventsystems/UI namespace is not included. Despite, there is a dll in Unity5\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll which includes these namespaces.
For mac, it's /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll.

How can I use Mono.Unix on Linux?

I have a C# app originally written in Windows that I'm now running in Linux on MonoDevelop. It works fine but now I need to recognise symbolic links. I found this answer but when I add:
using Mono.Unix;
I get the error "The type or namespace name 'Unix' does not exist in the namespace 'Mono'. Are you missing an assembly reference (CS0234)?"
You need to do what the error message says. Unintuitively, Mono.Unix lives in Mono.Posix.dll, so you need to add that as reference.

Compiling a standalone C# file at runtime which references another file

Using the code in this link I am attempting to compile a generated .cs file at runtime. The file (call it Gen.cs) has been generated by CodeDOM and subclasses another file (call it Base.cs). I get the following error message from the runtime compilation:
The type or namespace name `Base' could not be found. Are you missing a using directive or an assembly reference?
I know that this error means it can't find Base.cs when it's compiling. I'm new to both C# and compiling C# files dynamically, so this is a bit hard to pick apart. Neither Base nor Gen use namespaces, and both .cs files are in the same directory. Is there anything I'm missing? Why can't Gen.cs see Base.cs?
EDIT - This may or may not be relevant, but here's the result of a manual compilation via gmcs (I'm on MacOS)
mtrc$ gmcs -lib:Base.cs Gen.cs
Gen.cs(13,27): error CS0246: The type or namespace name
`Base' could not be found. Are you missing a using
directive or an assembly reference?
Typically a compiler will only compile source files that it's been told to compile in a single pass. ie: specify all .cs names on the command line, or specify to compile all .cs files in a given folder.
In this case:
string []arrCode = { code, "base.cs" };
CompilerResults results =
compiler.CompileAssemblyFromSource(compilerparams, arrCode);
Alternative syntax:
CompilerResults results =
compiler.CompileAssemblyFromSource(compilerparams, code, "base.cs");

ManagementBaseObject not found

Hi I'm having a problem implementing this method.
I have added using System.Management but the class still doesn't work.
The error is:
Error 7 The type or namespace name 'ManagementBaseObject' could not be found (are you missing a using directive or an assembly reference?)
You are probably missing the assembly reference to System.Management.dll. The using statement just brings names into scope, to save you typing the prefix: it doesn't actually add a DLL reference.
Right-click your project's References folder and choose Add Reference. Go to the .NET tab of the resulting dialog, select System.Management and click OK.
did you add System.Management.dll as a reference?
msdn tells us more about where to find ManagementBaseObject:
Namespace: System.Management
Assembly: System.Management (in
System.Management.dll)
Don't Forget to write using System.Management; after adding the reference some time this happens even after adding the respective assembly it shows the error.

Categories