Missing System.Devices library and problem constructing AQS strings - c#

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 —

Related

Error with UWP application in Visual Studio 2017

In my current UWP application, I am receiving 19062 errors, all of which begin with "The .winmd file (filename) contains type (type name) outside its root namespace (namespace name)." Examples of the full error code are shown below.
I have attempted the following to resolve the error:
Restarting Visual Studio
Rebuilding the Solution
Reinstalling the most recent version of the Windows SDK
Restarting my computer
The project was building fine a few days ago. Since then, I have not done anything to my computer which would result in such an issue with my solution.
Here are the error code examples:
"The .winmd file 'Windows.Foundation.UniversalApiContract.winmd' contains type 'Windows.ApplicationModel.Search.ISearchQueryLinguisticDetails' outside its root namespace 'Windows.Foundation.UniversalApiContract'. Make sure that all public types appear under a common root namespace that matches the output file name."
"The .winmd file 'Windows.Foundation.UniversalApiContract.winmd' contains type 'Windows.Graphics.Display.DisplayInformation'. The use of the Windows namespace is reserved."
"The .winmd file 'Windows.Foundation.UniversalApiContract.winmd' contains type 'Windows.UI.Xaml.Automation.IValuePatternIdentifiers' outside its root namespace 'Windows.Foundation.UniversalApiContract'. Make sure that all public types appear under a common root namespace that matches the output file name."
I am relatively new to UWP, and am failing to interpret the error. Any help would be much appreciated. Thanks in advance for any help.
Jordan.
The project needed to be cleaned to avoid these errors. OP confirmed in comments that it was a cause.

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.

What QuickBooks SDK 13.0 namespace is required to instantiate QBSessionManager?

I have downloaded QuickBooks SDK 13.0 and am trying to build a very simple C# application that connects to QuickBooks via QBSessionManager.
I am using Visual Studio Express 2013. I have the following lines of code in the Load function of my very simple Form.
QBSessionManager sessionManager = new QBSessionManager();
sessionManager.OpenConnection("", "Application");
When I try to compile, I get
The type or namespace name 'QBSessionManager' could not be found (are you missing a using directive or an assembly reference?)"
I see lots of sample code that starts with instantiating QBSessionManager, but nothing that identifes the namespace or reference I need to specify.
Am I missing something really obvious?
Add the file QBFC13Lib.dll to your project requirements.
The file can be found in the c:Program Files(x86)\Common Files\intuit\QuickBooks directory of a standard install of quickbooks.

Tesseract - Add reference does not works

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)?

Categories