【问题标题】:Uri namespace name could not be found in Unity C#在 Unity C# 中找不到 Uri 命名空间名称
【发布时间】:2019-09-17 07:09:18
【问题描述】:

我正在尝试创建一个函数,允许我在 HoloLens 中使用 LaunchUriAsync 打开另一个应用程序。我一步一步地遵循了 UWP API,但目前还停留在名义上的问题上。

代码如下:

'''

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 
     }
}

我在 Start() 和 LaunchApp() 中都为我的脚本使用了#if ENABLE_WINMD_SUPPORT,但它仍然返回“找不到类型或命名空间‘Uri’”。有什么我可以提供帮助的解决方案吗?

【问题讨论】:

  • 你添加using System;了吗?
  • 是的,现在“uri”在上下文中不存在,而“Uri”现在似乎没问题

标签: c# unity3d uwp hololens


【解决方案1】:
  1. Type or Namespace 'Uri' could not be found. 表示您错过了命名空间。查看报错信息会发现要求使用namespace System

  2. "uri" does not exist in context 是因为您试图使用在其他函数中声明的局部变量。只需将其声明为全局变量即可解决您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-28
    • 2011-06-28
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多