Xamarin Launcher.OpenAsync "request url too long"

Xamarin Launcher.OpenAsync "request url too long"

我正在尝试使用 URI 方案和 Xamarin Launcher.

将图像(不能是文件,必须是 base64)发送到另一个应用程序
var uri = new Uri(url);  
await Launcher.OpenAsync(uri); // await Launcher.OpenAsync(url);

如果 url 长度超过 2000 个字符,new Uri(url)await Launcher.OpenAsync(url) 都会给出例外。

据我所知,将 base64 字符串传递给其他应用程序(例如编辑图像或打印文档)是正常的。那么为什么 Xamarin 将其限制为 2000 个字符?

有解决办法吗?

编辑:
new Uri 异常:

System.UriFormatException: Invalid URI: The Uri string is too long.
  at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/System/net/System/UriExt.cs:55 
  at System.Uri..ctor (System.String uriString) [0x00014] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/System/net/System/URI.cs:408 

Launcher.OpenAsync 异常:

System.UriFormatException: Invalid URI: The Uri string is too long.
  at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/System/net/System/UriExt.cs:55 
  at System.Uri..ctor (System.String uriString) [0x00014] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/System/net/System/URI.cs:408 
  at Xamarin.Essentials.Launcher.OpenAsync (System.String uri) [0x00013] in D:\a\s\Xamarin.Essentials\Launcher\Launcher.shared.cs:32 

看来这是System.Uriclass的限制。虽然它没有正式记录,但如果您搜索,您会发现很多地方都在讨论这个问题,比如这里:https://social.msdn.microsoft.com/forums/en-US/6435996c-4b96-4887-be60-f6e10120f0a0/long-http-get-requests-and-a-uri-max-length-constraint

基本上你必须使用本机 classes 来实现你想要的。