【发布时间】:2020-07-13 15:40:55
【问题描述】:
System.ArgumentNullException: '值不能为空。 参数名称:流'
这是错误。一段时间以来一直在研究一些信息,但找不到答案。我从 GitHub 复制了代码和 json 文件。
代码:
void AddMapStyle()
{
var assembly = typeof(PinMap).GetTypeInfo().Assembly;
var stream = assembly.GetManifestResourceStream($"PcgDelivery.MapStyle.json");
string styleFile;
using (var reader = new System.IO.StreamReader(stream))
{
styleFile = reader.ReadToEnd();
}
map.MapStyle = MapStyle.FromJson(styleFile);
}
代码有问题还是什么? Json 文件放置正确。我也尝试了一些不同的方法来读取 json 文件,但是你可以看到没有结果。
【问题讨论】:
-
stream为空,这意味着GetManifestResourceStream肯定失败了。 -
我该怎么办?
-
很可能您的文件不在正确的位置,或者您用作参数的名称不正确。根据您发布的信息,我无法判断
标签: c# json xamarin xamarin.forms