'the type or namespace name 'mixedreality' does not exist in the namespace 'microsoft' (are you missing an assembly refrence?)

I am currently developing an app for the Hololens 2 with Unity and mrtk. I am trying to get the Gaze direction from the GazeProvider.cs which is attached to the camera, because i want to spawn objects in front of the players face. I am trying to access it like the mrtk site states:

void LogGazeDirectionOrigin()
{
    Debug.Log("Gaze is looking in direction: "
        + CoreServices.InputSystem.GazeProvider.GazeDirection);

    Debug.Log("Gaze origin is: "
        + CoreServices.InputSystem.GazeProvider.GazeOrigin);
} 

However when trying to using Microsoft.MixedReality.Toolkit; the error

the type or namespace name 'mixedreality' does not exist in the namespace 'microsoft' (are you missing an assembly refrence?)

occurs. Therefore CoreServices is also not recgonized. Also i recognised, that the GazeProvider.cs hat this path in the package folder Packages/com.microsoft.mixedreality.toolkit.foundation/Services/InputSystem/GazeProvider.cs. I don't know how to fix this or how to access the gaze direction of the player, i have been searching for a while now.

I would appreciate some help, thanks!



Solution 1:[1]

In order to get acces to the toolkit you probably have to install the package from the nuget package manager. Check out this Link to see how you can include it.

Solution 2:[2]

Thanks for the answers, but it unfortunately did nothing for me. I had to create a complete new project and migrated some prefabs i used there. Something with the Assemblies was broken and not created right. Some of the mrtk packages probably generated new assamblies, but i do not know which one.

Solution 3:[3]

File?Build Settings?Play Settings?As shown below in OtherSettings

enter image description here

Change it to the one that is different from the original, ctrl+s save can try it, thank you

Solution 4:[4]

Hi I’m Wayne Wang from the Microsoft for Founders Hub team!

Here is my suggestion:

  • make sure you are using latest "Mixed Reality Feature Tool" to install packages dependencies as "Local tarball"
  • Go to the unity menu: "Edit" ->"Preferences" ->"External Tools". It was the place you can change your visual studio versions.
  • You may see a list with checkbox looks like this List of checkboxes
  • Make sure the generation of "Local tarball" was selected

after the setting was saved, the pacakge you referenced may create new projects in your project of C#. These projects actually can be references of your current major project. The errors should be gone by then.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rbdeenk
Solution 2 Yannik
Solution 3 Housheng-MSFT
Solution 4 Wayne Wang - MSFT