Cannot build Unity project for HoloLens with IBM Watson SDK - visual-studio

I'm having troubles building my Unity project. I tried both a custom scene, created by me, and the example scenes located into Examples/ServiceExamples.
Basically, I want to take a picture with the HoloLens webcam and call IBM Watson visual recognition service. All Mixed Reality settings have been configured correctly. When I try to build the project I get lots of errors and they're all related to Watson SDK. For instance, the first error is the following:
Assets\Watson\ThirdParty\WebSocketSharp\Ext.cs(54,36): error CS0234: The type or namespace name 'X509Certificates' does not exist in the namespace 'System.Security.Cryptography' (are you missing an assembly reference?)
I tried to install directly from the solution some of these packages that i'm missing, but the error remains there. Do you think it could be due to my Visual Studio project settings (e.g.: .NET targets, ecc)?
Here are my Unity settings:
My settings imgur link
Am I missing something else? Any ideas? Thanks!

You have a Unity package recently added for this particular need, see https://github.com/watson-developer-cloud/unity-sdk/issues/173 I believe is not part of the official release as for now, but you can get it from GitHub.

Related

How to create a managed plugin for Unity with Visual Studio Community for Mac

I'm going to create my first managed plugin for Unity (2018.2) using Visual Studio Community for Mac (7.6.11 build 9).
I've read the documentation but I think that the step-by-step instructions are not meant to be followed on Visual Studio Community for Mac.
As you can see in the screenshot below, I've created several projects using each and every library template available.
All of them compiled successfully to a DLL targeting versions of .NET framework that are incompatible with Unity.
The only project I could change the .NET framework version to match Unity's 3.5 is the one based on the Other > .NET > Library.
Everything works fine but I'd like to know if the assumptions, the process and the final result are correct. Can you tell me, please?
I don't know the difference between the "Class" and the "Class Library" option but you're supposed to use the "Class Library" option. This is not the main point of this answer.
Two future issues you haven't solved yet:
1. Referencing Unity's API.
If you ever have to use any Unity library or API in youir plugin such as Vector3, you need to add Unity's UnityEngine.dll to your library settings. If you don't, you will run-time exceptions.
Go to Project --> Add Reference ---> Browse ---> Browse Button
then select <UnityInstallationDirecory>\Editor\Data\Managed\UnityEngine.dll. You can now build your managed plugin. Since you're using Mac, this path is different on your OS. On Mac, this could be /Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll. You just have to find where UnityEngine.dll is located.
2. Invisible stack trace
With your current setup, if you run into error with your managed plugin, the stack trace won't be there. You won't have the file names and line numbers and this makes is very hard to debug your plugin code.
When you build the project, Visual Studio generates a PDB file instead of an MDB file. Unity can't use this directly. You have to convert the PDB files into MDB files.
From command line, run this:
<UnityInstallationDirecory>\Data\MonoBleedingEdge\lib\mono\4.5\pdb2mdb.exe UnmanagedPlugin.dll
Again, the path might be different on Mac, you just need to find "pdb2mdb.exe" that converts the PDB files into MDB files.
After that, copy the MDB and dll file into the "Assets" folder in your Unity project.

The type or namespace name 'App' could not be found

Brand new Xamarin Cross-Platform project.
Solution comprises of:
A Xamarin (Xamarin Forms) android project
Shared (.NET Standard 2.0) Class Library
project, where 'App' is defined.
Both projects build with no errors or warnings.
However, when trying to run them I get the following error:
error: The type or namespace name 'App' could not be found (are you
missing a using directive or an assembly reference?) Failed to debug
your app.
It looks like a caching thing related to visual studio but I tried cleaning all caches (.vs, obj, release, restart VS, etc..)
Context:
I'm Using Visual Studio 2017.
Tried running the app on an emulator and on a real phone (Xamarin Live)
The app did run for a while but after an hour or so this error started popping out.
Tried plenty (I would love to say all but maybe missed one) solutions I found over SE and Xamarin forums. None helped.
I have found that this error occurs when I create a new project where the name and solution have a space. Try creating one without a space.
For example: "MyAwesomeApp" instead of "My Awesome App"

Add Reference is missing in Visual Studio when using with Unity 3D - Need Npgsql.dll

I installed Unity 2017 with Visual Studio 2017. I am attempting to add an external DLL to the Visual Studio project through the solution explorer. When I right click on References, the "Add Reference" option is completely missing!
I'm trying to use NpgSQL. Hence, the need to add npgsql.dll.
Can anyone give light?
The Add Reference... is in a different place in this case.
Things to do in Unity:
Create a folder named Plugins as a child to your Assets folder. (Assets\Plugins...)
Next copy your DLL to this plugins folder. You can do this using Windows Explorer or just drag it into the folder in the Unity editor, like shown:
Things to do in Visual Studio:
Click on Analyzers in your project as shown below, then click Project from your menu, then navigate to Add Reference...:
Now Browse to your DLL:
And... there it is:
Accepted Brien's answer (Thank you, Brien!).
I'm adding my own answer pertinent to Npgsql.dll, because it's apparently a common problem all over the internet with poor documentation. If you got here from google about Npgsql.dll then read on:
Unity (for some unknown reason) comes bundled with it's own npgsql.dll inside of the application mono/2_0 folder. Some people have reported conflicts with this.
Many of the npgsql.dll versions currently do not work with Unity. Attempting to include them in Unity's assets will cause Unity to throw a Type error. This is what caused me to think that I needed to add the file as a reference in C#. This is why I came here and asked the question about Add Reference. But, with Unity, this was simply wrong on my part.
As far as I can tell, Unity insists on managing all project properties and references for you. Both managed and unmanaged DLLs must be added via Unity assets. Even Visual Studio project properties cannot be changed within Visual Studio for Unity. And if you attempt to edit the .csproj files (for instance to disable compiler warnings), Unity will overwrite the .csproj files completely next time you load your Unity project.
Anyone who has problems getting Npgsql.dll to work in Unity needs to use the proper Unity workflow where you drop npgsql.dll into Unity assets. If you get errors, it's an npgsql.dll version conflict. Try other versions of the dll first.
This gentleman has provided a Unity specific build to resolve a namespace conflict (Just pull the dll from the bin folder on the Github link):
Unity NPGSQL.DLL
Unity 2017 currently allows you to change to .NET 4.6 as an experimental setting. Some people have toyed with using that setting to get newer versions of npgsql.dll to work properly, but they report intermittent results. For now, I solved my problem with Unitynpgsql.dll. It's an older build, so hopefully I won't run into any features I need that it doesn't support. If so, I'll probably just work around them.
To anyone else trying to make npgsql.dll work in Unity: do not despair, just try to resolve the version conflicts. Also here is another relevant recent thread about it:
Barebones Master Server Npgsql.dll Issue - January 2018

Getting "Cannot resolve assembly 'Xamarin.iOS.dll'" in UWP project...?

I've created a working iOS app with Visual Studio 2017 using Xamarin.Forms and a PCL. Now I'm trying to create the UWP app. I've followed the steps here, and when I build, I'm getting the error:
Cannot resolve Assembly or Metadata file 'Xamarin.iOS.dll'
It says it's happening in the MyProject.UWP project, in the MyProject.UWP.csproj file. But there's no reference to that file in MyProject.UWP.csproj (no reference to anything iOS), and there's no reference to that file in the entire UWP project either. So where is it trying to be referenced?
I did notice there's a file in MyProject.UWP\bin\ called project.assets.json. And while there are no references to 'Xamarin.iOS.dll', there are references to 'Xamarin.iOS10' - for example in the file list for the MR.Gestures package, I see listed a "lib/Xamarin.iOS10/MR.Gestures.dll" - not sure why there would be any iOS reference at all there, so that's a little suspicious...although it seems to reference all platforms, including windows phone and android, too, so maybe that's ok.

Difficulty with Adding a Reference in Visual Studio (Windows Azure StorageClient)

I've been following alone with this tutorial. Everything is going great, until I get to this part:
Set a reference to the StorageClient
library. You can either add the
sample project to the solution and add
a project reference or you can add a
reference to the compiled dll. I am
going to add the StorageClient project
to the solution and add a project
reference.
I am not able to find the StorageClient project. I have SDK v1.2, and it has samples-cs.zip. StorageClient is not there.
The SDK does have ref/Microsoft.WindowsAzure.StorageClient.dll. I tried adding a reference to it in my ASP project, but it's not working. VS does not recognize the type TableStorageEntity, nor the namespace Microsoft.Samples.ServiceHosting.StorageClient.
What am I doing wrong? Can I just find the StorageClient somewhere and use that? If it was taken out of the SDK, does it mean that it's not supported any more? If so, why have the DLL?
The problem is that the tutorial you're looking at is from mid-2009, when the storage client library was an add-on that was distributed as a sample with the SDK.
With the latest SDK (which I see you're using), the Azure storage support is now officially part of the SDK. The reference you're looking for is Microsoft.WindowsAzure.StorageClient.
Take a look at the Azure platform training kit - they should have updated samples.
Also: when you create a new cloud project with v1.2, you'll see that you automatically get references to the Azure dll's and don't need to manually add them. This includes:
Microsoft.WindowsAzure.Diagnostics
Microsoft.WindowsAzure.ServiceRuntime
Microsoft.WindowsAzure.StorageClient

Resources