【发布时间】:2020-05-06 22:22:27
【问题描述】:
我正在尝试在以 netcoreapp3.1 为目标的控制台应用程序中使用 System.Windows.Media.ImageSource。查看来自 Microsoft here 的文档,它似乎适用于 .NET Core 3.0 和 3.1
适用于 NET Core 3.1 3.0
我的示例代码在net472 时运行良好,但一旦我改回netcoreapp3.1,它将无法构建。
演示应用
using System;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace ImageSourceTesting
{
internal static class Program
{
private static void Main()
{
ImageSource myImage = new BitmapImage();
Console.Write(myImage);
}
}
}
在尝试构建时,我看到以下内容:
[CS0234] 类型或命名空间名称“Media”不存在于 命名空间“System.Windows”(您是否缺少程序集引用?)
【问题讨论】:
-
您是否包含适用于 .net core 3.1 的正确 NPM 包?