简体   繁体   English

无效的 URI:URI 方案无效。 - 新 Uri(“https://docs.microsoft.com/windows/msix/app-installer/update-settings”)

[英]Invalid URI: The URI scheme is not valid. - new Uri("​https://docs.microsoft.com/windows/msix/app-installer/update-settings")

I have a very simple 2 lines console app (.net 6) and whilst creating a Uri ,我有一个非常简单的 2 行控制台应用程序 (.net 6),在创建Uri时,

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
var uri = new Uri("​https://learn.microsoft.com/windows/msix/app-installer/update-settings");

I am getting the following exception.我收到以下异常。 I must be doing something really silly here, but can't figure it out.我一定是在这里做了一些非常愚蠢的事情,但无法弄清楚。 I have tried simple urls too with the same result.我也尝试过简单的网址,结果相同。

System.UriFormatException
  HResult=0x80131537
  Message=Invalid URI: The URI scheme is not valid.
  Source=System.Private.Uri
  StackTrace:
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Program.<Main>$(String[] args) in C:\Users\user\source\repos2\ConsoleApp1\ConsoleApp1\Program.cs:line 3

You have an additional symbol in string (it is not displayed here on SO).您在字符串中有一个附加符号(它未在此处显示)。 This is after copying from your question:这是在从您的问题中复制之后:

在此处输入图像描述

Delete this symbol before https and it will work.https之前的这个符号删掉就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM