Search Unity

Missing reference Exceptions when opening build solution

Discussion in 'Windows' started by Timelog, Jan 13, 2017.

  1. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Hey guys,

    I am playing around with integrating Cortana into a universal windows 10 application but I am running into a problem. When I build the Unity project a solution and project is generated at the build location, but when I open that project I get a ton of reference errors:
    Code (CSharp):
    1. Error CS4036 'IAsyncOperation<StorageFile>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation<StorageFile>' could be found (are you missing a using directive for 'System'?) MirrorVoice
    this is obviously because System is not referenced. Should I reference that manually, or is that something that should be resolved another way? If I reference them it would be default the the normal .Net references and not Mono, so I am not sure what to do atm.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you paste the contents of the output window? What happens when you build that project anyway?
     
  3. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Here is the output contents:
    Code (CSharp):
    1. Restoring NuGet packages...
    2. To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
    3. 1>------ Rebuild All started: Project: MirrorVoice, Configuration: Debug x86 ------
    4. 1>...\App.xaml.cs(83,21,83,104): error CS4036: 'IAsyncOperation<StorageFile>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation<StorageFile>' could be found (are you missing a using directive for 'System'?)
    5. 1>...\App.xaml.cs(85,17,87,87): error CS4036: 'IAsyncAction' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncAction' could be found (are you missing a using directive for 'System'?)
    6. 1>...\App.xaml.cs(89,20,89,29): error CS0246: The type or namespace name 'Exception' could not be found (are you missing a using directive or an assembly reference?)
    7. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
    8.  
    Now, initially it gave way more errors but a restart reduced that to only the lines I added, which are needed for the voice commands to work. These missing references should be under System though. For reference I am following the instruction from here: http://www.gamasutra.com/blogs/Simo...game_stand_out_with_Cortana_on_Windows_10.php

    Also, when I try to build I just get the message that build failed.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Any chance you are missing "using System;" in that file, like the error suggests?

    Code (csharp):
    1. are you missing a using directive for 'System'?
     
  5. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Yesy, indeed I am. Which brings me back to the question of whether I can savely add it :p But I just did it and it seems to work. Looks like the app generated is just a framework around Unity that uses the default .Net library, is that correct?
     
  6. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Yes, the generated solution uses the platform default .NET, the one your application will run in.
     
    Timelog likes this.
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    As long as you're using .NET scripting backend, yes. If you switched to IL2CPP, it would generate a C++ project, which doesn't use .NET at all.
     
    Timelog likes this.
  8. UweR7

    UweR7

    Joined:
    Jul 27, 2017
    Posts:
    20
    I have the same issue while "using System;" is added.
    I am using Unity 2018.3.6f1.
    Unity "player prefs" are set up for
    "Scripting Runtime Version*" = ".NET 4.x Equivalent"
    "Api Compatibiliy Level*" = ".NET 4.x"


    Code (CSharp):
    1. public static class AwaitExtensions
    2. {
    3.     public static AsyncOperationAwaiter GetAwaiter(this IAsyncOperation asyncOp) => new AsyncOperationAwaiter(asyncOp);
    4. }
    5.  
    What do I wrong?
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    What's the issue you get exactly?