WoofKita
WoofKita

Reputation: 15

Uri namespace name could not be found in Unity C#

I'm trying to create a function that allows me to open up another app with LaunchUriAsync in HoloLens. I've followed the UWP API step by step and am currently stuck with the titular question.

Here is the code:

'''

string uriToLaunch = @"ms-voip-video:?contactids=2914d36d-34f5-4f86-8196-52f4e53cf384";
public void Start()
{
    var uri = new Uri(uriToLaunch);
}


public async void LaunchApp()
{

var success = await Windows.System.Launcher.LaunchUriAsync(uri);

    if(success){
    //URI Launched
    }

    else{
 //Failed 
     }
}

I have used #if ENABLE_WINMD_SUPPORT for my scripts in both Start() and LaunchApp() but it still returns me a "Type or Namespace 'Uri' could not be found". Are there any solutions that I could do to help ?

Upvotes: 0

Views: 1074

Answers (1)

siusiulala
siusiulala

Reputation: 1060

  1. Type or Namespace 'Uri' could not be found. means you miss the namespace. Check the error message you will find that you are asked to use namespace System

  2. "uri" does not exist in context is caused by you're trying to use local variables declared in other function. Just declare it as a global variable will solve your problem.

Upvotes: 2

Related Questions