在 C# (NuGet) 中使用 Grib.Api

Use Grib.Api in C# (NuGet)

我正在尝试使用 Grib.Api 包读取 .grib 文件的内容。我使用的代码是从库的 gitHub 代码中提取的 (https://github.com/GribApiDotNet/GribApi.NET):

using (GribFile file = new GribFile(@"GribFiles\download.grib"))
{
    GribMessage msg = file.First();

    Console.WriteLine("Grid Type: " + msg.GridType);

    double latInDegrees = msg["latitudeOfFirstGridPoint"].AsDouble();
    // GribApi.NET normalizes the coordinate values to degrees. This follows the best practice advised by ECMWF.

    // values are also accessible as strings
    Console.WriteLine("latitudeOfFirstGridPointInDegrees = " + msg["latitudeOfFirstGridPoint"].AsString());
}

我已经使用 nuget 安装了库,但它找不到它(也找不到 GribFile class)。

有没有人遇到过这种情况?如果是这样,解决方案是什么?

PS。我还添加了环境。作者在 github 上推荐的变量。

谢谢!

我几乎可以肯定这是因为您正试图在 .net core 或 .net 5+ 项目中使用它;创建一个基于 .net 框架的框架。我对这个确切的库有类似的问题,设法在我的临时文件夹中找到这两个项目:

我没有深入研究 .net 核心的不兼容性,因为我只需要它来解码一个文件,所以只做了一个 NETFW472 项目..