【发布时间】:2020-11-19 17:47:17
【问题描述】:
我想使用Rect Struct,我写Rect aaa = new Rect();,我得到the type or namespace could not be found 错误。我尝试添加所有usings,如网络示例:
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
我知道最后三个导入 the type or namespace Shapes does not exist in the namespace System.Windows. (are you missing an assembly reference?)。
在提到的网页上,它说程序集是WindowsBase.dll。现在我不知道如何继续......
更新:我被告知要添加一个参考,但它是一个核心项目和that's not possible。
我应该安装一个包,但 I don't see any package 包含这个 dll。 WindowsBase 包对 .net 5 无效,但在上面的文档中说这个 Struc 确实可以与 .net 5 一起使用。
我想使用这个结构。
【问题讨论】:
-
您是否添加了 WindowsBase.dll 作为对 .csproj 文件的引用?
-
添加对
WindowBase的引用。 -
怎么样?在哪里?
<PackageReference Include="WindowsBase" />? -
我遵循了这些说明stackoverflow.com/a/20366962/11241615,但 WindowsBase 没有出现在 COM 选项卡中...
-
极少数需要 Rect 的项目类型已经包含了它。当您需要将其添加到其他东西时,这是奇怪和可疑的。另请注意,您的项目将不再是跨平台的,也不会在服务器上运行。